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
|
import { CdHelperClass } from './cd-helper.class';
class MockClass {
n = 42;
o = {
x: 'something',
y: [1, 2, 3],
z: true
};
b: boolean;
}
describe('CdHelperClass', () => {
describe('updateChanged', () => {
let old: MockClass;
let used: MockClass;
let structure = {
n: 42,
o: {
x: 'something',
y: [1, 2, 3],
z: true
}
} as any;
beforeEach(() => {
old = new MockClass();
used = new MockClass();
structure = {
n: 42,
o: {
x: 'something',
y: [1, 2, 3],
z: true
}
};
});
it('should not update anything', () => {
CdHelperClass.updateChanged(used, structure);
expect(used).toEqual(old);
});
it('should only change n', () => {
CdHelperClass.updateChanged(used, { n: 17 });
expect(used.n).not.toEqual(old.n);
expect(used.n).toBe(17);
});
it('should update o on change of o.y', () => {
CdHelperClass.updateChanged(used, structure);
structure.o.y.push(4);
expect(used.o.y).toEqual(old.o.y);
CdHelperClass.updateChanged(used, structure);
expect(used.o.y).toEqual([1, 2, 3, 4]);
});
it('should change b, o and n', () => {
structure.o.x.toUpperCase();
structure.n++;
structure.b = true;
CdHelperClass.updateChanged(used, structure);
expect(used).toEqual(structure);
});
});
});
|