@@ -3,7 +3,7 @@ import stylelint from "stylelint";
33import stylelintConfig from "stylelint-config-standard" ;
44import customSyntax from "../../src/index.js" ;
55import { getAllFixtureFilenames , getFixtureCode } from "../utils.js" ;
6- import * as assert from "uvu/assert" ;
6+ import { equal , is , not , ok , snapshot } from "uvu/assert" ;
77
88const stylelintRun = ( content , path , opts ) => {
99 return stylelint . lint ( {
@@ -36,14 +36,18 @@ autofixFiles.forEach(({ fixable, fixed }) => {
3636 const result = await stylelintRun ( fixture . code , fixture . path , {
3737 fix : true ,
3838 } ) ;
39- assert . is ( result . code , getFixtureCode ( fixed ) . code ) ;
39+ snapshot ( result . code , getFixtureCode ( fixed ) . code ) ;
4040 } ) ;
4141} ) ;
4242
4343const noSourceFixture = getFixtureCode ( "no-style.component.ts" ) ;
4444test ( `Test if stylelint considers this empty source: ${ noSourceFixture . filename } ` , async ( ) => {
4545 const result = await stylelintRun ( noSourceFixture . code , noSourceFixture . path ) ;
46- assert . equal ( result . results [ 0 ] . warnings , [ ] ) ;
46+ equal (
47+ result . results [ 0 ] . warnings . length ,
48+ 0 ,
49+ `Expected no warnings but the following warnings were raised: ${ result . results [ 0 ] . warnings } ` ,
50+ ) ;
4751} ) ;
4852
4953const emptySourceFixture = getFixtureCode ( "empty-style.component.ts" ) ;
@@ -52,17 +56,32 @@ test(`Test if stylelint considers this empty source: ${emptySourceFixture.filena
5256 emptySourceFixture . code ,
5357 emptySourceFixture . path ,
5458 ) ;
59+ ok ( result ) ;
60+ ok ( result . results [ 0 ] ) ;
5561
56- assert . equal ( result . results [ 0 ] . warnings [ 0 ] , {
57- line : 6 ,
58- column : 11 ,
59- endLine : 6 ,
60- endColumn : 12 ,
61- rule : "no-empty-source" ,
62- severity : "error" ,
63- text : "Unexpected empty source (no-empty-source)" ,
64- url : undefined ,
65- } ) ;
62+ const warnings = result . results [ 0 ] . warnings ;
63+ not . equal ( warnings , [ ] , "Expected warnings not to be empty" ) ;
64+ ok (
65+ warnings . map ( ( w ) => w . rule ) . includes ( "no-empty-source" ) ,
66+ `Expected a warning about empty source. Warnings: ${ warnings } ` ,
67+ ) ;
68+ } ) ;
69+
70+ const whitespaceFixture = getFixtureCode ( "whitespace.component.ts" ) ;
71+ test ( `Test if stylelint considers this empty source: ${ whitespaceFixture . filename } ` , async ( ) => {
72+ const result = await stylelintRun (
73+ whitespaceFixture . code ,
74+ whitespaceFixture . path ,
75+ ) ;
76+ ok ( result ) ;
77+ ok ( result . results [ 0 ] ) ;
78+
79+ const warnings = result . results [ 0 ] . warnings ;
80+ not . equal ( warnings , [ ] , "Expected warnings not to be empty" ) ;
81+ ok (
82+ warnings . map ( ( w ) => w . rule ) . includes ( "no-empty-source" ) ,
83+ `Expected a warning about empty source. Warnings: ${ warnings . toString ( ) } ` ,
84+ ) ;
6685} ) ;
6786
6887test . run ( ) ;
0 commit comments