-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathdeepCopyObject.test.js
More file actions
31 lines (27 loc) · 1.02 KB
/
deepCopyObject.test.js
File metadata and controls
31 lines (27 loc) · 1.02 KB
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
const copy = require("./deepCopyObject.js");
describe("copy()", () => {
describe("should deep copy an object with simple key-value pairs", () => {
it("tests if a deep copy of a simple object of number values has occured", () => {
const obj = { 1: 1, 2: 2, 3: 3, 4: 4 };
expect(copy(obj)).toEqual(obj);
});
it("tests if a deep copy of a simple object of string values has occured", () => {
const obj = { "1": "1", "2": "2", "3": "3" };
expect(copy(obj)).toEqual(obj);
});
it("it tests if a deep copy of an object filled with empty objects has occured", () => {
const obj = { 1: {}, 2: {}, 3: {} };
expect(copy(obj)).toEqual(obj);
});
});
describe("should deep copy an object with nested objects inside of it", () => {
it("tests if a deep copy of a complex, nested object has occured", () => {
const obj = {
1: 1,
2: 2,
3: { 4: 4, 5: { 6: 6, 7: { 8: { 9: { 10: 10 } } } } }
};
expect(copy(obj)).toEqual(obj);
});
});
});