Skip to content

Commit 75bbf81

Browse files
committed
test(e2e): add tests for css preprocessors
1 parent beb6f94 commit 75bbf81

File tree

1 file changed

+111
-0
lines changed

1 file changed

+111
-0
lines changed

tests/e2e/e2e_workflow.spec.js

+111
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,117 @@ describe('Basic end-to-end Workflow', function () {
192192
});
193193
});
194194

195+
it('Installs sass support successfully via `ng install sass`', function() {
196+
this.timeout(420000);
197+
198+
sh.exec('npm install node-sass', { silent: true });
199+
return ng(['generate', 'component', 'test-component'])
200+
.then(() => {
201+
let componentPath = path.join(process.cwd(), 'src', 'app', 'test-component');
202+
let cssFile = path.join(componentPath, 'test-component.css');
203+
let scssFile = path.join(componentPath, 'test-component.scss');
204+
205+
expect(existsSync(componentPath)).to.be.equal(true);
206+
sh.mv(cssFile, scssFile);
207+
expect(existsSync(scssFile)).to.be.equal(true);
208+
expect(existsSync(cssFile)).to.be.equal(false);
209+
let scssExample = '.outer {\n .inner { background: #fff; }\n }';
210+
fs.writeFileSync(scssFile, scssExample, 'utf8');
211+
212+
sh.exec('ng build --silent');
213+
let destCss = path.join(process.cwd(), 'dist', 'app', 'test-component', 'test-component.css');
214+
expect(existsSync(destCss)).to.be.equal(true);
215+
let contents = fs.readFileSync(destCss, 'utf8');
216+
expect(contents).to.include('.outer .inner');
217+
});
218+
});
219+
220+
it('Uninstalls sass support successfully via `ng uninstall sass`', function(done) {
221+
this.timeout(420000);
222+
223+
sh.exec('npm uninstall node-sass', { silent: true });
224+
let sassPath = path.join(process.cwd(), 'node_modules', 'node-sass');
225+
expect(existsSync(sassPath)).to.be.equal(false);
226+
return ng(['destroy', 'component', 'test-component'])
227+
.then(() => {
228+
sh.rm('-rf', path.join(process.cwd(), 'src', 'app', 'test-component'));
229+
done();
230+
});
231+
});
232+
233+
it('Installs less support successfully via `ng install less`', function() {
234+
this.timeout(420000);
235+
236+
sh.exec('npm install less', { silent: true });
237+
return ng(['generate', 'component', 'test-component'])
238+
.then(() => {
239+
let componentPath = path.join(process.cwd(), 'src', 'app', 'test-component');
240+
let cssFile = path.join(componentPath, 'test-component.css');
241+
let lessFile = path.join(componentPath, 'test-component.less');
242+
243+
expect(existsSync(componentPath)).to.be.equal(true);
244+
sh.mv(cssFile, lessFile);
245+
expect(existsSync(lessFile)).to.be.equal(true);
246+
expect(existsSync(cssFile)).to.be.equal(false);
247+
let lessExample = '.outer {\n .inner { background: #fff; }\n }';
248+
fs.writeFileSync(lessFile, lessExample, 'utf8');
249+
250+
sh.exec('ng build --silent');
251+
let destCss = path.join(process.cwd(), 'dist', 'app', 'test-component', 'test-component.css');
252+
expect(existsSync(destCss)).to.be.equal(true);
253+
let contents = fs.readFileSync(destCss, 'utf8');
254+
expect(contents).to.include('.outer .inner');
255+
});
256+
});
257+
258+
it('Uninstalls less support successfully via `ng uninstall less`', function() {
259+
this.timeout(420000);
260+
261+
sh.exec('npm uninstall less', { silent: true });
262+
let lessPath = path.join(process.cwd(), 'node_modules', 'less');
263+
expect(existsSync(lessPath)).to.be.equal(false);
264+
return ng(['destroy', 'component', 'test-component'])
265+
.then(() => {
266+
sh.rm('-rf', path.join(process.cwd(), 'src', 'app', 'test-component'));
267+
});
268+
});
269+
270+
it('Installs stylus support successfully via `ng install stylus`', function() {
271+
this.timeout(420000);
272+
273+
sh.exec('npm install stylus', { silent: true });
274+
return ng(['generate', 'component', 'test-component'])
275+
.then(() => {
276+
let componentPath = path.join(process.cwd(), 'src', 'app', 'test-component');
277+
let cssFile = path.join(componentPath, 'test-component.css');
278+
let stylusFile = path.join(componentPath, 'test-component.styl');
279+
280+
sh.mv(cssFile, stylusFile);
281+
expect(existsSync(stylusFile)).to.be.equal(true);
282+
expect(existsSync(cssFile)).to.be.equal(false);
283+
let stylusExample = '.outer {\n .inner { background: #fff; }\n }';
284+
fs.writeFileSync(stylusFile, stylusExample, 'utf8');
285+
286+
sh.exec('ng build --silent');
287+
let destCss = path.join(process.cwd(), 'dist', 'app', 'test-component', 'test-component.css');
288+
expect(existsSync(destCss)).to.be.equal(true);
289+
let contents = fs.readFileSync(destCss, 'utf8');
290+
expect(contents).to.include('.outer .inner');
291+
});
292+
});
293+
294+
it('Uninstalls stylus support successfully via `ng uninstall stylus`', function() {
295+
this.timeout(420000);
296+
297+
sh.exec('npm uninstall stylus', { silent: true });
298+
let stylusPath = path.join(process.cwd(), 'node_modules', 'stylus');
299+
expect(existsSync(stylusPath)).to.be.equal(false);
300+
return ng(['destroy', 'component', 'test-component'])
301+
.then(() => {
302+
sh.rm('-rf', path.join(process.cwd(), 'src', 'app', 'test-component'));
303+
});
304+
});
305+
195306
it('Turn on `noImplicitAny` in tsconfig.json and rebuild', function (done) {
196307
this.timeout(420000);
197308

0 commit comments

Comments
 (0)