-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathobjects_test.ts
38 lines (33 loc) · 1.32 KB
/
objects_test.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
import merge from "../src/index";
import { expect } from "chai";
import "mocha";
describe("Declaring an object", () => {
describe("with brackets", () => {
const base = "let searchTerm: {} = { id: Number };",
patch = "let secondSearchTerm: {} = { name: String };";
it("should yield a valid object declaration.", () => {
const result: String = merge(base, patch, true).replace(/\n/g, " ");
expect(result).equal(
" let searchTerm: {} = { id: Number }; let secondSearchTerm: {} = { name: String }; "
);
});
});
describe("with text", () => {
const base = "let searchTerm: any = { id: Number };",
patch = "let secondSearchTerm: String = { name: String };";
it("should yield a valid object declaration.", () => {
const result: String = merge(base, patch, true).replace(/\n/g, " ");
expect(result).equal(
" let searchTerm: any = { id: Number }; let secondSearchTerm: String = { name: String }; "
);
});
});
describe("while directly initializing it", () => {
const base = `export const environment: { production: string } = { production: 'yes' };`,
patch = "";
it("should yield a valid object declaration.", () => {
const result: String = merge(base, patch, true).replace(/\n/g, " ").trim();
expect(result).equal(base)
});
})
});