forked from ferdikoomen/openapi-typescript-codegen
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathformatCode.spec.ts
More file actions
40 lines (31 loc) · 787 Bytes
/
Copy pathformatCode.spec.ts
File metadata and controls
40 lines (31 loc) · 787 Bytes
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
import { formatCode } from './formatCode';
const input1 = `{ foo: true }`;
const output1 = `{ foo: true }`;
const input2 = `{ foo: true, bar: 123 }`;
const output2 = `{ foo: true, bar: 123 }`;
const input3 = `{
foo: true,
bar: 123
}`;
const output3 = `{
\tfoo: true,
\tbar: 123
}`;
const input4 = `{
\t\t\t\tfoo: true,
\t\t\t\tbar: 123
}`;
const output4 = `{
\tfoo: true,
\tbar: 123
}`;
describe('format', () => {
it('should produce correct result', () => {
expect(formatCode(``)).toEqual('');
expect(formatCode(`{}`)).toEqual('{}');
expect(formatCode(input1)).toEqual(output1);
expect(formatCode(input2)).toEqual(output2);
expect(formatCode(input3)).toEqual(output3);
expect(formatCode(input4)).toEqual(output4);
});
});