@@ -4,46 +4,38 @@ import { loadFeatured } from '../../src/build/featured'
44const ROOT = import . meta. dir + '/../..'
55
66describe ( 'loadFeatured' , ( ) => {
7- test ( 'loads every file in content/featured/ and returns them sorted by order ' , async ( ) => {
7+ test ( 'all content/featured/ files load without error ' , async ( ) => {
88 const labs = await loadFeatured ( ROOT )
9- expect ( labs . map ( ( l ) => l . title ) ) . toEqual ( [
10- 'Forms Lab' ,
11- 'Messaging Lab' ,
12- 'Document Extractor Lab' ,
13- ] )
9+ expect ( labs . length ) . toBeGreaterThan ( 0 )
1410 } )
1511
16- test ( 'Forms Lab has four typed links in document order ' , async ( ) => {
12+ test ( 'every lab has required fields ' , async ( ) => {
1713 const labs = await loadFeatured ( ROOT )
18- const forms = labs . find ( ( l ) => l . title === 'Forms Lab' ) !
19- expect ( forms . tagline ) . toBe (
20- 'Digitize forms to create modern, accessible experiences for public outreach.' ,
21- )
22- expect ( forms . order ) . toBe ( 1 )
23- expect ( forms . links ) . toHaveLength ( 4 )
24- expect ( forms . links . map ( ( l ) => l . kind ) ) . toEqual ( [ 'demo' , 'repo' , 'demo' , 'repo' ] )
25- expect ( forms . links [ 0 ] ) . toEqual ( {
26- label : 'Forms Platform' ,
27- url : 'https://10x-forms.labs.flexion.us/' ,
28- kind : 'demo' ,
29- } )
14+ for ( const lab of labs ) {
15+ expect ( typeof lab . title ) . toBe ( 'string' )
16+ expect ( lab . title . length ) . toBeGreaterThan ( 0 )
17+ expect ( typeof lab . tagline ) . toBe ( 'string' )
18+ expect ( lab . tagline . length ) . toBeGreaterThan ( 0 )
19+ expect ( typeof lab . order ) . toBe ( 'number' )
20+ expect ( lab . links . length ) . toBeGreaterThan ( 0 )
21+ }
3022 } )
3123
32- test ( 'Messaging Lab has a single repo link ' , async ( ) => {
24+ test ( 'every link has a valid kind and required fields ' , async ( ) => {
3325 const labs = await loadFeatured ( ROOT )
34- const messaging = labs . find ( ( l ) => l . title === 'Messaging Lab' ) !
35- expect ( messaging . links ) . toEqual ( [
36- {
37- label : 'flexion/flexion-messaging' ,
38- url : 'https://github.com/flexion/flexion-messaging' ,
39- kind : 'repo' ,
40- } ,
41- ] )
26+ const validKinds = new Set ( [ 'demo' , 'repo' , 'case-study' ] )
27+ for ( const lab of labs ) {
28+ for ( const link of lab . links ) {
29+ expect ( typeof link . label ) . toBe ( 'string' )
30+ expect ( typeof link . url ) . toBe ( 'string' )
31+ expect ( validKinds . has ( link . kind ) ) . toBe ( true )
32+ }
33+ }
4234 } )
4335
44- test ( 'Document Extractor Lab has repo and case-study kinds ' , async ( ) => {
36+ test ( 'labs are sorted by order ' , async ( ) => {
4537 const labs = await loadFeatured ( ROOT )
46- const doc = labs . find ( ( l ) => l . title === 'Document Extractor Lab' ) !
47- expect ( doc . links . map ( ( l ) => l . kind ) ) . toEqual ( [ 'repo' , 'case-study' ] )
38+ const orders = labs . map ( ( l ) => l . order )
39+ expect ( orders ) . toEqual ( [ ... orders ] . sort ( ( a , b ) => a - b ) )
4840 } )
4941} )
0 commit comments