1+ import { it , expect , describe } from 'vitest'
2+
3+ const arraysSnippets = require ( "../snippets/arrays.json" )
4+ const arrowSnippets = require ( "../snippets/arrow.json" )
5+ const promiseSnippets = require ( "../snippets/promise.json" )
6+ const functionJsSnippets = require ( "../snippets/function-js.json" )
7+ const functionTsSnippets = require ( "../snippets/var-ts.json" )
8+
9+ const snippets = {
10+ ...arraysSnippets ,
11+ ...arrowSnippets ,
12+ ...promiseSnippets ,
13+ ...functionJsSnippets ,
14+ ...functionTsSnippets ,
15+ }
16+
17+ const unique = ( xs ) => [ ...new Set ( xs ) ]
18+
19+ describe ( "snippets.json" , ( ) => {
20+ it ( "has entries" , ( ) => {
21+ expect ( Object . keys ( snippets ) . length ) . toBeGreaterThan ( 0 )
22+ } )
23+
24+ it ( "has unique prefixes" , ( ) => {
25+ const prefixes = Object . values ( snippets ) . map ( ( x ) => x . prefix )
26+ expect ( prefixes ) . toEqual ( unique ( prefixes ) )
27+ } )
28+
29+ describe . each ( Object . keys ( snippets ) ) ( "%s" , ( k ) => {
30+ it ( "has prefix" , ( ) => {
31+ const { prefix } = snippets [ k ]
32+ expect ( prefix ) . toBeDefined ( )
33+ expect ( prefix ) . not . toEqual ( "" )
34+ } )
35+
36+ it ( "has body" , ( ) => {
37+ const { body } = snippets [ k ]
38+ expect ( body ) . toBeDefined ( )
39+ expect ( body ) . not . toEqual ( "" )
40+ } )
41+
42+ it ( "has description" , ( ) => {
43+ const { description } = snippets [ k ]
44+ expect ( description ) . toBeDefined ( )
45+ expect ( description ) . not . toEqual ( "" )
46+ } )
47+ } )
48+ } )
0 commit comments