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
36 lines (26 loc) · 844 Bytes
/
Copy pathformatCode.spec.ts
File metadata and controls
36 lines (26 loc) · 844 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
import { EOL } from 'os';
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 = `{${EOL}\tfoo: true,${EOL}\tbar: 123${EOL}}`;
const input4 = `{
\t\t\t\tfoo: true,
\t\t\t\tbar: 123
}`;
const output4 = `{${EOL}\tfoo: true,${EOL}\tbar: 123${EOL}}`;
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);
});
});