@@ -30,25 +30,31 @@ function go(data: unknown, query: JSONQuery, options?: JSONQueryCompileOptions)
3030}
3131
3232const groupByCategory = compile ( [ 'groupBy' , [ 'get' , 'category' ] ] )
33- const testsByCategory = groupByCategory ( suite . tests ) as Record < string , CompileTestSuite [ 'tests ' ] >
33+ const testsByCategory = groupByCategory ( suite . groups ) as Record < string , CompileTestSuite [ 'groups ' ] >
3434
35- for ( const [ category , tests ] of Object . entries ( testsByCategory ) ) {
35+ for ( const [ category , testGroups ] of Object . entries ( testsByCategory ) ) {
3636 describe ( category , ( ) => {
37- for ( const currentTest of tests ) {
38- if ( isTestException ( currentTest ) ) {
39- test ( currentTest . description , ( ) => {
40- const { input, query, throws } = currentTest
41-
42- expect ( ( ) => compile ( query ) ( input ) ) . toThrow ( throws )
43- } )
44- } else {
45- test ( currentTest . description , ( ) => {
46- const { input, query, output } = currentTest
47- const actualOutput = compile ( query ) ( input )
48-
49- expect ( { input, query, output : actualOutput } ) . toEqual ( { input, query, output } )
50- } )
51- }
37+ for ( const group of testGroups ) {
38+ describe ( group . description , ( ) => {
39+ for ( const currentTest of group . tests ) {
40+ const description = `input = '${ currentTest . input } '`
41+
42+ if ( isTestException ( currentTest ) ) {
43+ test ( description , ( ) => {
44+ const { input, query, throws } = currentTest
45+
46+ expect ( ( ) => compile ( query ) ( input ) ) . toThrow ( throws )
47+ } )
48+ } else {
49+ test ( description , ( ) => {
50+ const { input, query, output } = currentTest
51+ const actualOutput = compile ( query ) ( input )
52+
53+ expect ( { input, query, output : actualOutput } ) . toEqual ( { input, query, output } )
54+ } )
55+ }
56+ }
57+ } )
5258 }
5359 } )
5460}
0 commit comments