-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathinline_type_test.ts
65 lines (61 loc) · 2.08 KB
/
inline_type_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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
import merge from '../src/index';
import { expect } from 'chai';
import 'mocha';
function splitLines(s: string): String[] {
return s.split('\n').filter(r => r.trim() != '')
}
function compareIgnoreSpace(s1: String, s2: String): boolean {
return s1.replace(' ', '') === s2.replace(' ', '')
}
describe('Merging inline interface type declarations with empty string', () => {
describe('Inline interface for variable', () => {
const base = 'let x: { y: SomeType, z: AnotherType };'
const patch = ''
it('Shouldn\'t change.', () => {
const result = splitLines(merge(base, patch, false))
const baseLines = splitLines(base)
expect(result.length).equal(baseLines.length)
for (let i in result) {
expect(compareIgnoreSpace(result[i], baseLines[i]))
}
})
})
describe('Inline interface for Parameter of Object type', () => {
const base = 'const k: ObjectClass<{ y: SomeType, z: AnotherType }> = new ObjectClass();'
const patch = ''
it('Shouldn\'t change.', () => {
const result = splitLines(merge(base, patch, false))
const baseLines = splitLines(base)
expect(result.length).equal(baseLines.length)
for (let i in result) {
expect(compareIgnoreSpace(result[i], baseLines[i]))
}
})
})
describe('Example from Issue', () => {
const base = `function getSampleData(size: number, page: number): Observable<{ content: SampledataModel[] }>
{
const searchCriteria: SearchCriteria = {
pageable: {
pageSize: size,
pageNumber: page,
},
name: searchTerms.name,
surname: searchTerms.surname,
};
return this.http.post<{ content: SampledataModel[] }>(
this.urlService + 'search',
searchCriteria,
);
}`
const patch = ''
it('Shouldn\'t change.', () => {
const result: String[] = splitLines(merge(base, patch, false))
const baseLines: String[] = splitLines(base)
expect(result.length).equal(baseLines.length)
for (let i in result) {
expect(result[i] == baseLines[i])
}
})
})
})