-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy patharrow_functions_test.ts
47 lines (46 loc) · 1.28 KB
/
arrow_functions_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
import merge from '../src/index';
import { expect } from 'chai';
import 'mocha';
describe('should merge expression statements', () => {
const base = `describe('SidenavSharedService', () => {
beforeEach(() => {
TestBed.configureTestingModule({
providers: [],
imports: [
RouterTestingModule,
CoreModule,
],
});
});`,
patch = `describe('arg', () => {
beforeEach(() => {
TestBed.configureTestingModule({
providers: [],
imports: [
patchImport,
],
});
});`;
it('including arrow functions.', () => {
const result: String[] = merge(base, patch, false)
.split('\n')
.map((value) => value.trim())
.filter((value) => value != '');
expect(
result.filter((res) =>
/describe\.\('SidenavSharedService',\s*\(\)\s*=>\s*{/.test(
res.toString(),
),
),
).length.to.be.greaterThan(
0,
'base should have its two parameters untouched',
);
expect(
result.filter((res) => /patchImport/.test(res.toString())),
).length.to.be.greaterThan(0, 'should have merged patch import too');
expect(
result.filter((res) => /},\s*'arg',\s*\);/.test(res.toString())),
).length.to.be.greaterThan(0, 'should have merged patch argument too');
});
});