@@ -49,10 +49,11 @@ fs.__setMockFiles([
4949] ) ;
5050
5151describe ( 'postcss-import-sub' , ( ) => {
52+
5253 it ( 'relative `to` substitution' , ( ) => {
5354 const render = mockRender ( sub ( [
5455 {
55- id : new RegExp ( " red\.css" ) ,
56+ id : / r e d \. c s s / ,
5657 to : "blue.css"
5758 }
5859 ] ) ) ;
@@ -65,7 +66,7 @@ describe('postcss-import-sub', () => {
6566 it ( 'relative `to` substitution with dot' , ( ) => {
6667 const render = mockRender ( sub ( [
6768 {
68- id : new RegExp ( " red\.css" ) ,
69+ id : / r e d \. c s s / ,
6970 to : "./blue.css"
7071 }
7172 ] ) ) ;
@@ -78,7 +79,7 @@ describe('postcss-import-sub', () => {
7879 it ( 'absolute `to` substitution' , ( ) => {
7980 const render = mockRender ( sub ( [
8081 {
81- id : new RegExp ( " red\.css" ) ,
82+ id : / r e d \. c s s / ,
8283 to : "<root>/app/Components/Box/blue.css"
8384 }
8485 ] ) ) ;
@@ -91,7 +92,7 @@ describe('postcss-import-sub', () => {
9192 it ( 'relative `path` substitution with dot' , ( ) => {
9293 const render = mockRender ( sub ( [
9394 {
94- id : new RegExp ( " red\.css" ) ,
95+ id : / r e d \. c s s / ,
9596 path : "<root>/app/Theme/Components/Box/"
9697 }
9798 ] ) ) ;
@@ -104,7 +105,7 @@ describe('postcss-import-sub', () => {
104105 it ( 'relative `path` substitution with without ending slash' , ( ) => {
105106 const render = mockRender ( sub ( [
106107 {
107- id : new RegExp ( " red\.css" ) ,
108+ id : / r e d \. c s s / ,
108109 path : "<root>/app/Theme/Components/Box"
109110 }
110111 ] ) ) ;
@@ -117,7 +118,7 @@ describe('postcss-import-sub', () => {
117118 it ( 'absolute `to` substitution with alias' , ( ) => {
118119 const render = mockRender ( sub ( [
119120 {
120- id : new RegExp ( " red\.css" ) ,
121+ id : / r e d \. c s s / ,
121122 to : "<root>/app/Theme/Components/Box/<id>"
122123 }
123124 ] ) ) ;
@@ -130,7 +131,7 @@ describe('postcss-import-sub', () => {
130131 it ( 'absolute `to` substitution with alias' , ( ) => {
131132 const render = mockRender ( sub ( [
132133 {
133- id : new RegExp ( " red\.css" ) ,
134+ id : / r e d \. c s s / ,
134135 to : "<root>/app/Theme/Components/Box/<id>"
135136 }
136137 ] ) ) ;
@@ -143,7 +144,7 @@ describe('postcss-import-sub', () => {
143144 it ( 'relative `path` with custom aliases' , ( ) => {
144145 const render = mockRender ( sub ( [
145146 {
146- id : new RegExp ( " red\.css" ) ,
147+ id : / r e d \. c s s / ,
147148 base : / C o m p o n e n t s \/ ( [ a - z 0 - 9 ] + ) \/ / i,
148149 path : "<root>/app/Theme/Components/<base:$1>/"
149150 }
@@ -180,4 +181,34 @@ describe('postcss-import-sub', () => {
180181 expect ( module [ 0 ] ) . toBe ( "app/Theme/Components/Box/red.css" ) ;
181182 } ) ;
182183 } ) ;
184+
185+ it ( 'append mode' , ( ) => {
186+ const render = mockRender ( sub ( [
187+ {
188+ module : / \/ ( [ a - z 0 - 9 ] + ) \/ ( [ a - z 0 - 9 ] + ) \. c s s / i,
189+ to : "<root>/app/Theme/Components/<module:$1>/<module:$2>.css" ,
190+ append : true
191+ }
192+ ] ) ) ;
193+ return render ( "red.css" , "app/Components/Box/" )
194+ . then ( function ( module ) {
195+ expect ( module [ 0 ] ) . toBe ( "app/Components/Box/red.css" ) ;
196+ expect ( module [ 1 ] ) . toBe ( "app/Theme/Components/Box/red.css" ) ;
197+ } ) ;
198+ } ) ;
199+
200+ it ( 'append mode unresolved' , ( ) => {
201+ const render = mockRender ( sub ( [
202+ {
203+ module : / n o .c s s / i,
204+ to : "<root>/app/Theme/Components/<module:$1>/<module:$2>.css" ,
205+ append : true
206+ }
207+ ] ) ) ;
208+ return render ( "red.css" , "app/Components/Box/" )
209+ . then ( function ( module ) {
210+ expect ( module [ 0 ] ) . toBe ( "red.css" ) ;
211+ expect ( module . length ) . toBe ( 1 ) ;
212+ } ) ;
213+ } ) ;
183214} ) ;
0 commit comments