@@ -13,7 +13,17 @@ describe('postcss.config.ts - {Object} - Load Config', test => {
1313 syntax : true
1414 }
1515
16- const expected = config => {
16+ test ( 'Load Config - postcss.config.ts (CommonJS)' , async ( ) => {
17+ const config = await postcssrc ( ctx , 'test/ts/object/cjs-in-ts' )
18+ assertExpectedConfig ( config , 'test/ts/object/cjs-in-ts/postcss.config.ts' )
19+ } )
20+
21+ test ( 'Load Config - postcss.config.cts' , async ( ) => {
22+ const config = await postcssrc ( ctx , 'test/ts/object/cts' )
23+ assertExpectedConfig ( config , 'test/ts/object/cts/postcss.config.cts' )
24+ } )
25+
26+ function assertExpectedConfig ( config , expectedPath ) {
1727 is ( config . options . parser , require ( 'sugarss' ) )
1828 is ( config . options . syntax , require ( 'sugarss' ) )
1929 is ( config . options . map , false )
@@ -24,13 +34,9 @@ describe('postcss.config.ts - {Object} - Load Config', test => {
2434 is ( typeof config . plugins [ 0 ] , 'function' )
2535 is ( typeof config . plugins [ 1 ] , 'function' )
2636
27- is ( config . file , path . resolve ( 'test/ts/object' , 'postcss.config.ts' ) )
37+ is ( config . file , path . resolve ( expectedPath ) )
2838 }
2939
30- test ( 'Async' , ( ) => {
31- return postcssrc ( ctx , 'test/ts/object' ) . then ( expected )
32- } )
33-
3440 test . run ( )
3541} )
3642
@@ -40,7 +46,7 @@ test('postcss.config.ts - {Object} - Process CSS', () => {
4046 syntax : false
4147 }
4248
43- return postcssrc ( ctx , 'test/ts/object' ) . then ( config => {
49+ return postcssrc ( ctx , 'test/ts/object/cjs-in-ts ' ) . then ( config => {
4450 return postcss ( config . plugins )
4551 . process ( fixture ( 'ts/object' , 'index.css' ) , config . options )
4652 . then ( result => {
@@ -56,7 +62,7 @@ test('postcss.config.ts - {Object} - Process SSS', () => {
5662 syntax : false
5763 }
5864
59- return postcssrc ( ctx , 'test/ts/object' ) . then ( config => {
65+ return postcssrc ( ctx , 'test/ts/object/cjs-in-ts ' ) . then ( config => {
6066 return postcss ( config . plugins )
6167 . process ( fixture ( 'ts/object' , 'index.sss' ) , config . options )
6268 . then ( result => {
@@ -71,7 +77,17 @@ describe('postcss.config.ts - {Array} - Load Config', () => {
7177 syntax : true
7278 }
7379
74- const expected = config => {
80+ test ( 'Load Config - postcss.config.ts (CommonJS)' , async ( ) => {
81+ const config = await postcssrc ( ctx , 'test/ts/array/cjs-in-ts' )
82+ assertExpectedConfig ( config , 'test/ts/array/cjs-in-ts/postcss.config.ts' )
83+ } )
84+
85+ test ( 'Load Config - postcss.config.cts' , async ( ) => {
86+ const config = await postcssrc ( ctx , 'test/ts/array/cts' )
87+ assertExpectedConfig ( config , 'test/ts/array/cts/postcss.config.cts' )
88+ } )
89+
90+ function assertExpectedConfig ( config , expectedPath ) {
7591 is ( config . options . parser , require ( 'sugarss' ) )
7692 is ( config . options . syntax , require ( 'sugarss' ) )
7793 is ( config . options . map , false )
@@ -82,13 +98,9 @@ describe('postcss.config.ts - {Array} - Load Config', () => {
8298 is ( typeof config . plugins [ 0 ] , 'object' )
8399 is ( typeof config . plugins [ 1 ] , 'object' )
84100
85- is ( config . file , path . resolve ( 'test/ts/array' , 'postcss.config.ts' ) )
101+ is ( config . file , path . resolve ( expectedPath ) )
86102 }
87103
88- test ( 'Async' , ( ) => {
89- return postcssrc ( ctx , 'test/ts/array' ) . then ( expected )
90- } )
91-
92104 test . run ( )
93105} )
94106
@@ -98,7 +110,7 @@ test('postcss.config.ts - {Array} - Process CSS', () => {
98110 syntax : false
99111 }
100112
101- return postcssrc ( ctx , 'test/ts/array' ) . then ( config => {
113+ return postcssrc ( ctx , 'test/ts/array/cjs-in-ts ' ) . then ( config => {
102114 return postcss ( config . plugins )
103115 . process ( fixture ( 'ts/array' , 'index.css' ) , config . options )
104116 . then ( result => {
@@ -114,7 +126,7 @@ test('postcss.config.ts - {Array} - Process SSS', () => {
114126 syntax : false
115127 }
116128
117- return postcssrc ( ctx , 'test/ts/array' ) . then ( config => {
129+ return postcssrc ( ctx , 'test/ts/array/cjs-in-ts ' ) . then ( config => {
118130 return postcss ( config . plugins )
119131 . process ( fixture ( 'ts/array' , 'index.sss' ) , config . options )
120132 . then ( result => {
0 commit comments