test(bazel): Integration test for Sass support (#28297)

Add .sass files to the integration test for bazel-schematics.

Also addressed Alex's comment in
https://github.com/angular/angular/pull/28167/files#r248149866
about the unit tests being too brittle.

PR Close #28297
This commit is contained in:
Keen Yee Liau 2019-01-17 13:21:31 -08:00 committed by Jason Aden
parent bb94434d85
commit c84739dc55
3 changed files with 6 additions and 20 deletions

View File

@ -23,7 +23,7 @@
"src/assets"
],
"styles": [
"src/styles.css"
"src/styles.scss"
],
"scripts": []
},
@ -82,7 +82,7 @@
"tsConfig": "src/tsconfig.spec.json",
"karmaConfig": "src/karma.conf.js",
"styles": [
"src/styles.css"
"src/styles.scss"
],
"scripts": [],
"assets": [

View File

@ -7,10 +7,11 @@ function testBazel() {
bazel version
rm -rf demo
# Create project
ng new demo --collection=@angular/bazel --defaults --skip-git
ng new demo --collection=@angular/bazel --defaults --skip-git --style=scss
node replace_angular_repo.js "./demo/WORKSPACE"
cd demo
cp ../package.json.replace ./package.json
ng generate component widget --style=css
ng build
ng test
ng e2e

View File

@ -91,32 +91,17 @@ describe('Bazel-workspace Schematic', () => {
expect(host.files).toContain('/src/BUILD.bazel');
});
it('should download rules_sass in WORKSPACE', () => {
it('should download and load rules_sass in WORKSPACE', () => {
const content = host.readContent('/WORKSPACE');
expect(content).toContain('RULES_SASS_VERSION');
expect(content).toContain('io_bazel_rules_sass');
});
it('should load sass_repositories in WORKSPACE', () => {
const content = host.readContent('/WORKSPACE');
expect(content).toContain(
'load("@io_bazel_rules_sass//sass:sass_repositories.bzl", "sass_repositories")');
expect(content).toContain('sass_repositories()');
});
it('should add sass_binary rules in src/BUILD', () => {
const content = host.readContent('/src/BUILD.bazel');
expect(content).toContain('load("@io_bazel_rules_sass//:defs.bzl", "sass_binary")');
expect(content).toMatch(/sass_binary\((.*\n)+\)/);
});
it('should add SASS targets to assets of ng_module in src/BUILD', () => {
const content = host.readContent('/src/BUILD.bazel');
expect(content).toContain(`
assets = glob([
"**/*.css",
"**/*.html",
]) + [":style_" + x for x in glob(["**/*.scss"])],`);
expect(content).toContain('glob(["**/*.scss"])');
});
});
});