@@ -9,8 +9,8 @@ const processor = postcss().use(atImport())
99
1010test ( "should warn when not @charset and not @import statement before" , t => {
1111 return Promise . all ( [
12- processor . process ( `a {} @import "";` ) ,
13- processor . process ( `@media {} @import "";` ) ,
12+ processor . process ( `a {} @import "";` , { from : undefined } ) ,
13+ processor . process ( `@media {} @import "";` , { from : undefined } ) ,
1414 ] ) . then ( results => {
1515 results . forEach ( result => {
1616 const warnings = result . warnings ( )
@@ -30,7 +30,8 @@ test("should warn about all imports after some other CSS declaration", t => {
3030 a {}
3131 @import "a.css";
3232 @import "b.css";
33- `
33+ ` ,
34+ { from : undefined }
3435 )
3536 . then ( result => {
3637 t . plan ( 2 )
@@ -44,16 +45,18 @@ test("should warn about all imports after some other CSS declaration", t => {
4445} )
4546
4647test ( "should not warn if comments before @import" , t => {
47- return processor . process ( `/* skipped comment */ @import "";` ) . then ( result => {
48- const warnings = result . warnings ( )
49- t . is ( warnings . length , 1 )
50- t . is ( warnings [ 0 ] . text , `Unable to find uri in '@import ""'` )
51- } )
48+ return processor
49+ . process ( `/* skipped comment */ @import "";` , { from : undefined } )
50+ . then ( result => {
51+ const warnings = result . warnings ( )
52+ t . is ( warnings . length , 1 )
53+ t . is ( warnings [ 0 ] . text , `Unable to find uri in '@import ""'` )
54+ } )
5255} )
5356
5457test ( "should warn if something before comments" , t => {
5558 return processor
56- . process ( `a{} /* skipped comment */ @import "";` )
59+ . process ( `a{} /* skipped comment */ @import "";` , { from : undefined } )
5760 . then ( result => {
5861 t . is ( result . warnings ( ) . length , 1 )
5962 } )
@@ -75,15 +78,17 @@ test("should not warn when @charset or @import statement before", t => {
7578} )
7679
7780test ( "should warn when a user didn't close an import with ;" , t => {
78- return processor . process ( `@import url('http://') :root{}` ) . then ( result => {
79- const warnings = result . warnings ( )
80- t . is ( warnings . length , 1 )
81- t . is (
82- warnings [ 0 ] . text ,
83- "It looks like you didn't end your @import statement correctly. " +
84- "Child nodes are attached to it."
85- )
86- } )
81+ return processor
82+ . process ( `@import url('http://') :root{}` , { from : undefined } )
83+ . then ( result => {
84+ const warnings = result . warnings ( )
85+ t . is ( warnings . length , 1 )
86+ t . is (
87+ warnings [ 0 ] . text ,
88+ "It looks like you didn't end your @import statement correctly. " +
89+ "Child nodes are attached to it."
90+ )
91+ } )
8792} )
8893
8994test ( "should warn on invalid url" , t => {
@@ -97,7 +102,8 @@ test("should warn on invalid url", t => {
97102 @import url();
98103 @import url('');
99104 @import url("");
100- `
105+ ` ,
106+ { from : undefined }
101107 )
102108 . then ( result => {
103109 const warnings = result . warnings ( )
@@ -113,7 +119,9 @@ test("should warn on invalid url", t => {
113119} )
114120
115121test ( "should not warn when a user closed an import with ;" , t => {
116- return processor . process ( `@import url('http://');` ) . then ( result => {
117- t . is ( result . warnings ( ) . length , 0 )
118- } )
122+ return processor
123+ . process ( `@import url('http://');` , { from : undefined } )
124+ . then ( result => {
125+ t . is ( result . warnings ( ) . length , 0 )
126+ } )
119127} )
0 commit comments