massive update, probably broken
[dotfiles/.git] / .config / coc / extensions / node_modules / coc-prettier / node_modules / @humanwhocodes / object-schema / tests / merge-strategy.js
1 /**
2  * @filedescription Merge Strategy Tests
3  */
4 /* global it, describe, beforeEach */
5
6 "use strict";
7
8 //-----------------------------------------------------------------------------
9 // Requirements
10 //-----------------------------------------------------------------------------
11
12 const assert = require("chai").assert;
13 const { MergeStrategy } = require("../src/");
14
15 //-----------------------------------------------------------------------------
16 // Class
17 //-----------------------------------------------------------------------------
18
19 describe("MergeStrategy", () => {
20
21
22     describe("overwrite()", () => {
23
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);
27         });
28
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);
32         });
33
34     });
35
36     describe("replace()", () => {
37
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);
41         });
42
43         it("should return the first value when the second is undefined", () => {
44             const result = MergeStrategy.replace(1, undefined);
45             assert.strictEqual(result, 1);
46         });
47
48     });
49
50     describe("assign()", () => {
51
52         it("should merge properties from two objects when called", () => {
53
54             const object1 = { foo: 1, bar: 3 };
55             const object2 = { foo: 2 };            
56             
57             const result = MergeStrategy.assign(object1, object2);
58             assert.deepStrictEqual(result, {
59                 foo: 2,
60                 bar: 3
61             });
62         });
63
64     });
65
66 });