1
+ let { Readable } = require ( 'stream' )
1
2
let $ = require ( '../../execute' )
2
3
let { css, html, javascript } = require ( '../../syntax' )
3
4
@@ -10,6 +11,18 @@ function ready(message) {
10
11
return message . includes ( 'Done in' )
11
12
}
12
13
14
+ class ReadableString extends Readable {
15
+ constructor ( string ) {
16
+ super ( )
17
+ this . data = string
18
+ }
19
+
20
+ _read ( ) {
21
+ this . push ( this . data )
22
+ this . push ( null )
23
+ }
24
+ }
25
+
13
26
describe ( 'static build' , ( ) => {
14
27
it ( 'should be possible to generate tailwind output' , async ( ) => {
15
28
await writeInputFile ( 'index.html' , html `<div class= "font-bold" > </ div> ` )
@@ -27,6 +40,30 @@ describe('static build', () => {
27
40
)
28
41
} )
29
42
43
+ it ( 'should be possible to pipe in data' , async ( ) => {
44
+ await writeInputFile ( 'index.html' , html `<div class= "font-bold" > </ div> ` )
45
+
46
+ let initialCss = css `
47
+ @tailwind base;
48
+ @tailwind components;
49
+ @tailwind utilities;
50
+ `
51
+ let customStdin = new ReadableString ( initialCss )
52
+
53
+ await $ ( 'node ../../lib/cli.js -o ./dist/main.css' , {
54
+ stdio : [ customStdin , 'pipe' , 'pipe' ] ,
55
+ env : { NODE_ENV : 'production' } ,
56
+ } )
57
+
58
+ expect ( await readOutputFile ( 'main.css' ) ) . toIncludeCss (
59
+ css `
60
+ .font-bold {
61
+ font-weight : 700 ;
62
+ }
63
+ `
64
+ )
65
+ } )
66
+
30
67
it ( 'should safelist a list of classes to always include' , async ( ) => {
31
68
await writeInputFile ( 'index.html' , html `<div class= "font-bold" > </ div> ` )
32
69
await writeInputFile (
0 commit comments