@@ -3,19 +3,22 @@ const expect = require('expect');
33const fs = require ( 'fs' ) ;
44const plugin = require ( '../' ) ;
55const tcpp = require ( 'tcp-ping' ) ;
6+ const log = require ( 'ololog' ) ;
67
7- const fixture1Css = fs . readFileSync ( __dirname + '/fixture-1/style.css' , { encoding : 'utf8' } ) ;
8+ const fixture1Css = fs . readFileSync ( __dirname + '/fixture-1/style.css' , {
9+ encoding : 'utf8' ,
10+ } ) ;
811
912const testEqual = function ( input , output , pluginOptions , postcssOptions , done ) {
10- getResult ( input , pluginOptions , postcssOptions ) . then ( ( result ) => {
13+ getResult ( input , pluginOptions , postcssOptions ) . then ( result => {
1114 expect ( result . css . trim ( ) ) . toEqual ( output . trim ( ) ) ;
1215 expect ( result . warnings ( ) ) . toHaveLength ( 0 ) ;
1316 done ( ) ;
1417 } , done ) ;
1518} ;
1619
1720const testContains = function ( input , value , pluginOptions , postcssOptions , done ) {
18- getResult ( input , pluginOptions , postcssOptions ) . then ( ( result ) => {
21+ getResult ( input , pluginOptions , postcssOptions ) . then ( result => {
1922 expect ( result . css ) . toContain ( value ) ;
2023 expect ( result . warnings ( ) ) . toHaveLength ( 0 ) ;
2124 done ( ) ;
@@ -50,7 +53,8 @@ describe('import with media queries', function () {
5053 } ) ;
5154
5255 it ( 'rule print' , function ( done ) {
53- const input = "@import url('http://fonts.googleapis.com/css?family=Tangerine') print" ;
56+ const input =
57+ "@import url('http://fonts.googleapis.com/css?family=Tangerine') print" ;
5458 testContains ( input , '@media print' , { } , { } , done ) ;
5559 } ) ;
5660
@@ -106,7 +110,8 @@ describe('import url tangerine', function () {
106110 }
107111
108112 it ( 'empty' , async ( ) => {
109- const input = "@import 'http://fonts.googleapis.com/css?family=Tangerine' ;" ;
113+ const input =
114+ "@import 'http://fonts.googleapis.com/css?family=Tangerine' ;" ;
110115 const result = await getResult ( input ) ;
111116 assertOutputTangerine ( result ) ;
112117 } ) ;
@@ -124,13 +129,15 @@ describe('import url tangerine', function () {
124129 } ) ;
125130
126131 it ( 'url single quotes' , async ( ) => {
127- const input = "@import url('http://fonts.googleapis.com/css?family=Tangerine');" ;
132+ const input =
133+ "@import url('http://fonts.googleapis.com/css?family=Tangerine');" ;
128134 const result = await getResult ( input ) ;
129135 assertOutputTangerine ( result ) ;
130136 } ) ;
131137
132138 it ( 'url double quotes' , async ( ) => {
133- const input = '@import url("http://fonts.googleapis.com/css?family=Tangerine");' ;
139+ const input =
140+ '@import url("http://fonts.googleapis.com/css?family=Tangerine");' ;
134141 const result = await getResult ( input ) ;
135142 assertOutputTangerine ( result ) ;
136143 } ) ;
@@ -143,7 +150,7 @@ describe('import url tangerine', function () {
143150} ) ;
144151
145152describe ( 'recursive import' , function ( ) {
146- it ( 'ping server' , ( done ) => {
153+ it ( 'ping server' , done => {
147154 tcpp . probe ( 'localhost' , 1234 , function ( err ) {
148155 done ( err ) ;
149156 } ) ;
@@ -218,7 +225,13 @@ describe('recursive import', function () {
218225
219226 it ( 'does not resolve relative URLs when option.resolveURLs is false' , function ( done ) {
220227 const input = '@import url(http://localhost:1234/fixture-3/style.css)' ;
221- testContains ( input , "src: url('./font.woff');" , { resolveUrls : false } , { } , done ) ;
228+ testContains (
229+ input ,
230+ "src: url('./font.woff');" ,
231+ { resolveUrls : false } ,
232+ { } ,
233+ done ,
234+ ) ;
222235 } ) ;
223236
224237 var _opts = { resolveUrls : true } ;
@@ -341,14 +354,36 @@ describe('recursive import', function () {
341354describe ( 'google font woff' , function ( ) {
342355 it ( 'option modernBrowser should import woff' , function ( done ) {
343356 const input = '@import url(http://fonts.googleapis.com/css?family=Tangerine);' ;
344- testContains ( input , "woff2) format('woff2')" , { modernBrowser : true } , { } , done ) ;
357+ testContains (
358+ input ,
359+ "woff2) format('woff2')" ,
360+ { modernBrowser : true } ,
361+ { } ,
362+ done ,
363+ ) ;
345364 } ) ;
346365
347366 it ( 'option agent should import woff' , function ( done ) {
348367 const input = '@import url(http://fonts.googleapis.com/css?family=Tangerine);' ;
349368 var opts = {
350- userAgent : 'Mozilla/5.0 AppleWebKit/537.36 Chrome/80.0.2840.99 Safari/537.36' ,
369+ userAgent :
370+ 'Mozilla/5.0 AppleWebKit/537.36 Chrome/80.0.2840.99 Safari/537.36' ,
351371 } ;
352372 testContains ( input , "woff2) format('woff2')" , opts , { } , done ) ;
353373 } ) ;
354374} ) ;
375+
376+ describe ( 'source property' , ( ) => {
377+ it ( 'regular import' , async ( ) => {
378+ const input = '@import url(http://fonts.googleapis.com/css?family=Tangerine)' ;
379+ const result = await getResult ( input ) ;
380+ expect ( result . root . source . input . css ) . toEqual ( input ) ;
381+ } ) ;
382+
383+ it ( 'media import' , async ( ) => {
384+ const input =
385+ '@import url(http://fonts.googleapis.com/css?family=Tangerine) print' ;
386+ const result = await getResult ( input ) ;
387+ expect ( result . root . source . input . css ) . toEqual ( input ) ;
388+ } ) ;
389+ } ) ;
0 commit comments