@@ -33,4 +33,49 @@ describe('Svelte Check', () => {
3333 }
3434 assert . equal ( exitCode , 0 , 'Expected check to pass (exit code 0)' ) ;
3535 } ) ;
36+
37+ it ( 'should pass check on valid children usage' , async ( ) => {
38+ const root = fileURLToPath ( new URL ( './fixtures/prop-types/types/children' , import . meta. url ) ) ;
39+ const tsConfigPath = fileURLToPath (
40+ new URL ( './fixtures/prop-types/tsconfig.children-pass.json' , import . meta. url ) ,
41+ ) ;
42+ const { getResult } = cli ( 'check' , '--tsconfig' , tsConfigPath , '--root' , root ) ;
43+ const { exitCode, stdout, stderr } = await getResult ( ) ;
44+
45+ if ( exitCode !== 0 ) {
46+ console . error ( stdout ) ;
47+ console . error ( stderr ) ;
48+ }
49+ assert . equal ( exitCode , 0 , 'Expected check to pass (exit code 0)' ) ;
50+ } ) ;
51+
52+ it ( 'should fail check on invalid text children' , async ( ) => {
53+ const root = fileURLToPath ( new URL ( './fixtures/prop-types/types/children' , import . meta. url ) ) ;
54+ const tsConfigPath = fileURLToPath (
55+ new URL ( './fixtures/prop-types/tsconfig.children-fail.json' , import . meta. url ) ,
56+ ) ;
57+ const { getResult } = cli ( 'check' , '--tsconfig' , tsConfigPath , '--root' , root ) ;
58+ const { exitCode, stdout } = await getResult ( ) ;
59+
60+ assert . equal ( exitCode , 1 , 'Expected check to fail (exit code 1)' ) ;
61+ assert . ok (
62+ stdout . includes ( `'Empty' components don't accept text` ) ,
63+ 'Expected Empty component error' ,
64+ ) ;
65+ assert . ok (
66+ stdout . includes ( `'EmptyV5' components don't accept text` ) ,
67+ 'Expected EmptyV5 component error' ,
68+ ) ;
69+ } ) ;
70+
71+ it ( 'should fail check on invalid element children' , { skip : true } , async ( ) => {
72+ const root = fileURLToPath ( new URL ( './fixtures/prop-types/types/children' , import . meta. url ) ) ;
73+ const tsConfigPath = fileURLToPath (
74+ new URL ( './fixtures/prop-types/tsconfig.children-fail-element.json' , import . meta. url ) ,
75+ ) ;
76+ const { getResult } = cli ( 'check' , '--tsconfig' , tsConfigPath , '--root' , root ) ;
77+ const { exitCode } = await getResult ( ) ;
78+
79+ assert . equal ( exitCode , 1 , 'Expected check to fail (exit code 1)' ) ;
80+ } ) ;
3681} ) ;
0 commit comments