-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.js
49 lines (43 loc) · 1.08 KB
/
test.js
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
const { lint, format } = require( './' )
test( 'lint and format is defined', () => {
expect( typeof lint ).toBe( 'function' )
expect( typeof format ).toBe( 'function' )
} )
test( 'lint - basic', () => {
const string = `
{
// hello
"json": {
"a": "value",
},
'b': 1
}
`
const result = lint( string )
expect( typeof result ).toBe( 'object' )
expect( result.source ).toBe( string )
expect( result.errors.length ).toBe( 3 )
expect( result.comments.length ).toBe( 1 )
expect( typeof result.codeframe ).toBe( 'string' )
const formatted = format( result )
expect( typeof formatted ).toBe( 'string' )
} )
test( 'lint - allowComments', () => {
const string = `
{
// hello
"json": {
"a": "value",
},
'b': 1
}
`
const result = lint( string, {
allowComments: true
} )
expect( typeof result ).toBe( 'object' )
expect( result.source ).toBe( string )
expect( result.errors.length ).toBe( 2 )
expect( result.comments.length ).toBe( 1 )
expect( typeof result.codeframe ).toBe( 'string' )
} )