11import { DiagnosticSeverity } from '@stoplight/types' ;
22import * as fs from 'fs' ;
33import { join } from 'path' ;
4+
45import { parseWithPointers } from '../parseWithPointers' ;
56
67const simple = fs . readFileSync ( join ( __dirname , './fixtures/simple.json' ) , 'utf-8' ) ;
78
89describe ( 'json parser' , ( ) => {
9- test ( 'parse simple' , ( ) => {
10+ it ( 'parse simple' , ( ) => {
1011 expect ( parseWithPointers ( simple ) ) . toMatchSnapshot ( {
1112 ast : expect . any ( Object ) ,
1213 lineMap : expect . any ( Array ) ,
1314 } ) ;
1415 } ) ;
1516
16- test ( 'parse complex' , ( ) => {
17+ it ( 'parse complex' , ( ) => {
1718 expect (
1819 parseWithPointers ( `{
1920 "users": [
@@ -40,7 +41,7 @@ describe('json parser', () => {
4041 } ) ;
4142 } ) ;
4243
43- test ( 'does not allow comments by default' , ( ) => {
44+ it ( 'does not allow comments by default' , ( ) => {
4445 expect (
4546 parseWithPointers ( `{
4647 // a comment
@@ -72,7 +73,7 @@ describe('json parser', () => {
7273 ] ) ;
7374 } ) ;
7475
75- test ( 'does not allow trailing commas by default' , ( ) => {
76+ it ( 'does not allow trailing commas by default' , ( ) => {
7677 expect (
7778 parseWithPointers ( `{
7879 "name": "Antti",
@@ -105,7 +106,7 @@ describe('json parser', () => {
105106 } ) ;
106107
107108 describe ( 'fixtures' , ( ) => {
108- test . each ( [ 'petstore.oas2.json' , 'user.jschema.json' ] ) ( 'parses %s' , async filename => {
109+ it . each ( [ 'petstore.oas2.json' , 'user.jschema.json' ] ) ( 'parses %s' , async filename => {
109110 expect (
110111 parseWithPointers ( ( await fs . promises . readFile ( join ( __dirname , 'fixtures' , filename ) , 'utf-8' ) ) as string ) ,
111112 ) . toMatchSnapshot ( {
@@ -116,12 +117,11 @@ describe('json parser', () => {
116117 } ) ;
117118
118119 describe ( 'invalid fixtures' , ( ) => {
119- test . each ( [ 'schema.json' , 'characters.json' ] ) ( 'parses %s' , async filename => {
120+ it . each ( [ 'schema.json' , 'characters.json' ] ) ( 'parses %s' , async filename => {
120121 expect (
121- parseWithPointers ( ( await fs . promises . readFile (
122- join ( __dirname , 'fixtures/invalid' , filename ) ,
123- 'utf-8' ,
124- ) ) as string ) ,
122+ parseWithPointers (
123+ ( await fs . promises . readFile ( join ( __dirname , 'fixtures/invalid' , filename ) , 'utf-8' ) ) as string ,
124+ ) ,
125125 ) . toMatchSnapshot ( {
126126 ast : expect . any ( Object ) ,
127127 lineMap : expect . any ( Array ) ,
@@ -130,7 +130,7 @@ describe('json parser', () => {
130130 } ) ;
131131
132132 describe ( 'duplicate keys' , ( ) => {
133- test ( 'given object with no duplicate keys, does not report any errors' , ( ) => {
133+ it ( 'given object with no duplicate keys, does not report any errors' , ( ) => {
134134 expect (
135135 parseWithPointers (
136136 `{
@@ -181,7 +181,7 @@ describe('json parser', () => {
181181 ) . toEqual ( [ ] ) ;
182182 } ) ;
183183
184- test ( 'given object containing with duplicate keys, reports them' , ( ) => {
184+ it ( 'given object containing with duplicate keys, reports them' , ( ) => {
185185 expect (
186186 parseWithPointers (
187187 `{
@@ -278,7 +278,7 @@ describe('json parser', () => {
278278 ] ) ;
279279 } ) ;
280280
281- test ( 'generates correct paths for dupes in arrays' , ( ) => {
281+ it ( 'generates correct paths for dupes in arrays' , ( ) => {
282282 expect (
283283 parseWithPointers ( '{ "A": [{}, { "foo": true, "foo": false,\n "foo": 2 }] }' , { ignoreDuplicateKeys : false } ) ,
284284 ) . toHaveProperty ( 'diagnostics' , [
@@ -313,7 +313,7 @@ describe('json parser', () => {
313313 } ) ;
314314 } ) ;
315315
316- test ( 'includes properties with empty string as keys' , ( ) => {
316+ it ( 'includes properties with empty string as keys' , ( ) => {
317317 expect ( parseWithPointers ( '{ "": [{ "foo": true, "": false }] }' ) ) . toHaveProperty ( 'data' , {
318318 '' : [ { '' : false , foo : true } ] ,
319319 } ) ;
@@ -372,7 +372,9 @@ describe('json parser', () => {
372372 } ) ;
373373
374374 it ( 'does not touch arrays' , ( ) => {
375- const { data } = parseWithPointers ( `[0, 1, 2]` , { preserveKeyOrder : true } ) ;
375+ const { data } = parseWithPointers ( `[0, 1, 2]` , {
376+ preserveKeyOrder : true ,
377+ } ) ;
376378
377379 expect ( Object . keys ( data ) ) . toEqual ( [ '0' , '1' , '2' ] ) ;
378380 expect ( Object . getOwnPropertySymbols ( data ) ) . toEqual ( [ ] ) ;
0 commit comments