48 lines
1.3 KiB
JavaScript
48 lines
1.3 KiB
JavaScript
import { deepClone } from "./object-cloning-helper";
|
|
|
|
describe("object-cloning-helper.js", () => {
|
|
it("Should return null if no object is passed in", async () => {
|
|
// Arrange
|
|
const expected = null;
|
|
|
|
// Act
|
|
const result = deepClone(null);
|
|
|
|
// Assert
|
|
expect(result).toEqual(expected);
|
|
});
|
|
|
|
it("Should return a deep copy of the object", async () => {
|
|
// Arrange
|
|
|
|
const object = {
|
|
addressQuestions: {
|
|
streetAddress: "555 Some St",
|
|
apartmentNumberOrBusinessName: "Apt 1",
|
|
city: "Funkytown",
|
|
state: "OH",
|
|
zipCode: "55555",
|
|
},
|
|
isVehicleProtected: true,
|
|
serviceZipCode: "55555",
|
|
};
|
|
|
|
const expected = {
|
|
addressQuestions: {
|
|
streetAddress: "555 Some St",
|
|
apartmentNumberOrBusinessName: "Apt 1",
|
|
city: "Funkytown",
|
|
state: "OH",
|
|
zipCode: "55555",
|
|
},
|
|
isVehicleProtected: true,
|
|
serviceZipCode: "55555",
|
|
};
|
|
|
|
// Act
|
|
const result = deepClone(object);
|
|
|
|
// Assert
|
|
expect(result).toStrictEqual(expected);
|
|
});
|
|
});
|