yzt
2023-05-26 de4278af2fd46705a40bac58ec01122db6b7f3d7
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
import { combine } from "../../Source/Cesium.js";
 
describe("Core/combine", function () {
  it("can combine shallow references", function () {
    var obj1 = {
      x: 1,
      y: 2,
      other: {
        value1: 0,
      },
    };
    var obj2 = {
      x: -1,
      z: 3,
      other: {
        value2: 1,
      },
    };
    var composite = combine(obj1, obj2);
    expect(composite).toEqual({
      x: 1,
      y: 2,
      z: 3,
      other: {
        value1: 0,
      },
    });
  });
 
  it("can combine deep references", function () {
    var object1 = {
      one: 1,
      deep: {
        value1: 10,
      },
    };
    var object2 = {
      two: 2,
      deep: {
        value1: 5,
        value2: 11,
        sub: {
          val: "a",
        },
      },
    };
 
    var composite = combine(object1, object2, true);
    expect(composite).toEqual({
      one: 1,
      two: 2,
      deep: {
        value1: 10,
        value2: 11,
        sub: {
          val: "a",
        },
      },
    });
  });
 
  it("can accept undefined as either object", function () {
    var object = {
      one: 1,
      deep: {
        value1: 10,
      },
    };
 
    expect(combine(undefined, object)).toEqual(object);
    expect(combine(undefined, object, true)).toEqual(object);
    expect(combine(object, undefined)).toEqual(object);
    expect(combine(object, undefined, true)).toEqual(object);
 
    expect(combine(undefined, undefined)).toEqual({});
    expect(combine(undefined, undefined, true)).toEqual({});
  });
});