2 * @filedescription Merge Strategy Tests
4 /* global it, describe, beforeEach */
8 //-----------------------------------------------------------------------------
10 //-----------------------------------------------------------------------------
12 const assert = require("chai").assert;
13 const { MergeStrategy } = require("../src/");
15 //-----------------------------------------------------------------------------
17 //-----------------------------------------------------------------------------
19 describe("MergeStrategy", () => {
22 describe("overwrite()", () => {
24 it("should overwrite the first value with the second when the second is defined", () => {
25 const result = MergeStrategy.overwrite(1, 2);
26 assert.strictEqual(result, 2);
29 it("should overwrite the first value with the second when the second is undefined", () => {
30 const result = MergeStrategy.overwrite(1, undefined);
31 assert.strictEqual(result, undefined);
36 describe("replace()", () => {
38 it("should overwrite the first value with the second when the second is defined", () => {
39 const result = MergeStrategy.replace(1, 2);
40 assert.strictEqual(result, 2);
43 it("should return the first value when the second is undefined", () => {
44 const result = MergeStrategy.replace(1, undefined);
45 assert.strictEqual(result, 1);
50 describe("assign()", () => {
52 it("should merge properties from two objects when called", () => {
54 const object1 = { foo: 1, bar: 3 };
55 const object2 = { foo: 2 };
57 const result = MergeStrategy.assign(object1, object2);
58 assert.deepStrictEqual(result, {