@@ -2,11 +2,13 @@ import test from 'ava';
22import path from 'path' ;
33import fs from 'fs-extra' ;
44import rcsCore from 'rcs-core' ;
5+ import { minify } from 'html-minifier' ;
56
67import rcs from '../' ;
78
8- const testCwd = 'test/files/testCache' ;
9- const fixturesCwd = 'test/files/fixtures' ;
9+ const testFiles = 'test/files' ;
10+ const testCwd = path . join ( testFiles , 'testCache' ) ;
11+ const fixturesCwd = path . join ( testFiles , 'fixtures' ) ;
1012
1113test . beforeEach ( ( ) => {
1214 rcsCore . nameGenerator . setAlphabet ( '#abcdefghijklmnopqrstuvwxyz' ) ;
@@ -54,3 +56,56 @@ test.cb('issue #19 | detect one file', (t) => {
5456 } ) ;
5557 } ) ;
5658} ) ;
59+
60+ test . cb ( 'issue #21 | with auto' , ( t ) => {
61+ const issueFixture = path . join ( testFiles , 'issue21/fixtures' ) ;
62+ const issueResults = path . join ( testFiles , 'issue21/results' ) ;
63+
64+ rcs . process . auto ( [ 'style.css' , 'index.html' ] , {
65+ newPath : testCwd ,
66+ cwd : issueFixture ,
67+ } , ( err ) => {
68+ t . falsy ( err ) ;
69+
70+ const newCss = fs . readFileSync ( path . join ( testCwd , '/style.css' ) , 'utf8' ) ;
71+ const newHtml = fs . readFileSync ( path . join ( testCwd , '/index.html' ) , 'utf8' ) ;
72+ const expectedCss = fs . readFileSync ( path . join ( issueResults , '/style.css' ) , 'utf8' ) ;
73+ const expectedHtml = fs . readFileSync ( path . join ( issueResults , '/index.html' ) , 'utf8' ) ;
74+
75+ t . is ( newCss , expectedCss ) ;
76+ t . is (
77+ minify ( newHtml , { collapseWhitespace : true } ) ,
78+ minify ( expectedHtml , { collapseWhitespace : true } ) ,
79+ ) ;
80+
81+ t . end ( ) ;
82+ } ) ;
83+ } ) ;
84+
85+ test . cb ( 'issue #21 | with seperated process functions' , ( t ) => {
86+ const issueFixture = path . join ( testFiles , 'issue21/fixtures' ) ;
87+ const issueResults = path . join ( testFiles , 'issue21/results' ) ;
88+
89+ rcs . process . css ( 'style.css' , {
90+ newPath : testCwd ,
91+ cwd : issueFixture ,
92+ } , ( ) => {
93+ rcs . process . html ( 'index.html' , {
94+ newPath : testCwd ,
95+ cwd : issueFixture ,
96+ } , ( ) => {
97+ const newCss = fs . readFileSync ( path . join ( testCwd , '/style.css' ) , 'utf8' ) ;
98+ const newHtml = fs . readFileSync ( path . join ( testCwd , '/index.html' ) , 'utf8' ) ;
99+ const expectedCss = fs . readFileSync ( path . join ( issueResults , '/style.css' ) , 'utf8' ) ;
100+ const expectedHtml = fs . readFileSync ( path . join ( issueResults , '/index.html' ) , 'utf8' ) ;
101+
102+ t . is ( newCss , expectedCss ) ;
103+ t . is (
104+ minify ( newHtml , { collapseWhitespace : true } ) ,
105+ minify ( expectedHtml , { collapseWhitespace : true } ) ,
106+ ) ;
107+
108+ t . end ( ) ;
109+ } ) ;
110+ } ) ;
111+ } ) ;
0 commit comments