File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11'use strict' ;
22
3- var _interopRequireWildcard = function ( obj ) { return obj && obj . __esModule ? obj : { 'default' : obj } ; } ;
4-
53Object . defineProperty ( exports , '__esModule' , {
64 value : true
75} ) ;
86
7+ function _interopRequireDefault ( obj ) { return obj && obj . __esModule ? obj : { 'default' : obj } ; }
8+
99var _postcss = require ( 'postcss' ) ;
1010
11- var _postcss2 = _interopRequireWildcard ( _postcss ) ;
11+ var _postcss2 = _interopRequireDefault ( _postcss ) ;
12+
13+ var processor = function processor ( css , result ) { } ;
1214
13- exports [ 'default' ] = function ( css , result ) { } ;
15+ processor . defaultRandomStr = function ( ) {
16+ return Math . random ( ) . toString ( 36 ) . substr ( 2 , 8 ) ;
17+ } ;
18+ processor . getRandomStr = processor . defaultRandomStr ; // Easy to be mocked out
1419
20+ exports [ 'default' ] = processor ;
1521module . exports = exports [ 'default' ] ;
Original file line number Diff line number Diff line change 11import postcss from 'postcss'
22
3- export default ( css , result ) => {
3+ const processor = ( css , result ) => {
4+
45}
6+
7+ processor . defaultRandomStr = ( ) => Math . random ( ) . toString ( 36 ) . substr ( 2 , 8 )
8+ processor . getRandomStr = processor . defaultRandomStr // Easy to be mocked out
9+
10+ export default processor
Original file line number Diff line number Diff line change @@ -3,16 +3,24 @@ import postcss from "postcss"
33import processor from "./index.src.js"
44
55let pipeline = postcss ( [ processor ] ) ,
6- check = ( desc , input , expected ) => {
6+ check = ( desc , input , expected , randomStrs ) => {
77 it ( desc , ( ) => {
8+ processor . getRandomStr = randomStrs ? ( ) => randomStrs . shift ( ) : processor . defaultRandomStr
89 assert . equal ( pipeline . process ( input ) . css , expected )
910 } )
1011 }
1112
1213describe ( "processor" , ( ) => {
1314 check (
14- "it should do nothing" ,
15- "a { b: c; }" ,
16- "a { b: c; }"
15+ "it should extract an import within a :local" ,
16+ `:local(.exportName) { extends: importName from "path/library.css"; other: rule; }` ,
17+ `:import("path/library.css") { importName: __tmp-rand0ml0l0l; } :local(.exportName) { extends: __tmp-rand0ml0l0l; other: rule; }` ,
18+ [ "rand0ml0l0l" ]
1719 )
20+
21+ it ( "it should not care if single-quotes are used" )
22+ it ( "should import multiple classes on a single line" )
23+ it ( "should consolidate imports by file for multiple files and multiple classes" )
24+ it ( "should ignore imports not inside a :local" )
25+ it ( "should ignore imports not inside our rule whitelist" )
1826} )
You can’t perform that action at this time.
0 commit comments