-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathenum_test.ts
50 lines (48 loc) · 1.62 KB
/
enum_test.ts
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
import merge from '../src/index';
import { expect } from 'chai';
import 'mocha';
describe('should merge enums', () => {
const base = `export enum Direction {
Up = 1,
Down = 2,
}`,
patch = `enum Direction {
Up = 0,
Left = 3,
Right = 4,
}`;
it('the enum should contain all the elements and Up element should equal 1.', () => {
const result: String[] = merge(base, patch, false)
.split('\n')
.map((value) => value.trim())
.filter((value) => value != '');
expect(
result.filter((res) =>
/export\s*enum\s+Direction\s*\{\s*Up\s*=\s*1,\s*Down\s*=\s*2,\s*Left\s*=\s*3,\s*Right\s*=\s*4,\s*}/.test(
res.toString(),
),
),
).length.to.be.greaterThan(
0,
'enum not correct, does not contain all elements. Result is ' +
result.reduce((prev, curr) => prev.toString() + curr.toString(), ''),
);
});
it('when patchOverride is true, enum should contain all elements and Up element should equal 0.', () => {
const result: String[] = merge(base, patch, true)
.split('\n')
.map((value) => value.trim())
.filter((value) => value != '');
expect(
result.filter((res) =>
/enum\s+Direction\s*\{\s*Up\s*=\s*0,\s*Down\s*=\s*2,\s*Left\s*=\s*3,\s*Right\s*=\s*4,\s*}/.test(
res.toString(),
),
),
).length.to.be.greaterThan(
0,
'enum not correct, does not contain all elements. Result is ' +
result.reduce((prev, curr) => prev.toString() + curr.toString(), ''),
);
});
});