mirror of
https://github.com/angular/angular.git
synced 2026-09-14 13:54:52 +08:00
chore: update to angular 8.0.0-rc.1 (#15909)
* chore: update to angular 8.0.0-rc.1 * build: use ts-api-guardian from npm * update rules_nodejs * update to rc.1 * updgrade ts-api-guardian * update @angular-devkit * don't rename symbols that start with ɵɵ * add @bazel/bazel to dev deps * fix e2e deps * fix schematic tests
This commit is contained in:
@@ -5,8 +5,8 @@ load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
|
||||
# Add NodeJS rules (explicitly used for sass bundle rules)
|
||||
http_archive(
|
||||
name = "build_bazel_rules_nodejs",
|
||||
sha256 = "88e5e579fb9edfbd19791b8a3c6bfbe16ae3444dba4b428e5efd36856db7cf16",
|
||||
urls = ["https://github.com/bazelbuild/rules_nodejs/releases/download/0.27.8/rules_nodejs-0.27.8.tar.gz"],
|
||||
sha256 = "4c702ffeeab2d24dd4101601b6d27cf582d2e0d4cdc3abefddd4834664669b6b",
|
||||
urls = ["https://github.com/bazelbuild/rules_nodejs/releases/download/0.28.0/rules_nodejs-0.28.0.tar.gz"],
|
||||
)
|
||||
|
||||
# Add sass rules
|
||||
@@ -68,23 +68,6 @@ rules_sass_dependencies()
|
||||
load("@io_bazel_rules_sass//:defs.bzl", "sass_repositories")
|
||||
sass_repositories()
|
||||
|
||||
# Temporarily add the Angular repository so that we can set up "ts_api_guardian".
|
||||
# TODO(jelbourn): remove this once we can do all the same stuff via @npm//@angular
|
||||
http_archive(
|
||||
name = "angular",
|
||||
sha256 = "a542f00adf5cafbcad24268d69da8e4746c22619699f29c3b3b0259d0ce52974",
|
||||
url = "https://github.com/angular/angular/archive/8.0.0-beta.6.zip",
|
||||
strip_prefix = "angular-8.0.0-beta.6",
|
||||
)
|
||||
|
||||
# Only install the "ts-api-guardian" dependencies as we don't want to install the
|
||||
# Angular dev dependencies which are not needed.
|
||||
yarn_install(
|
||||
name = "ts-api-guardian_deps",
|
||||
package_json = "@angular//tools/ts-api-guardian:package.json",
|
||||
yarn_lock = "@angular//tools/ts-api-guardian:yarn.lock",
|
||||
)
|
||||
|
||||
# Bring in bazel_toolchains for RBE setup configuration.
|
||||
http_archive(
|
||||
name = "bazel_toolchains",
|
||||
|
||||
+22
-21
@@ -29,42 +29,42 @@
|
||||
"format": "git-clang-format HEAD $(git diff HEAD --name-only | grep -v \"\\.d\\.ts\")"
|
||||
},
|
||||
"version": "8.0.0-beta.2",
|
||||
"requiredAngularVersion": ">=7.0.0",
|
||||
"requiredAngularVersion": ">=8.0.0-rc.1",
|
||||
"requiredMDCVersion": "^1.1.0",
|
||||
"dependencies": {
|
||||
"@angular/animations": "8.0.0-beta.10",
|
||||
"@angular/common": "8.0.0-beta.10",
|
||||
"@angular/compiler": "8.0.0-beta.10",
|
||||
"@angular/core": "8.0.0-beta.10",
|
||||
"@angular/elements": "8.0.0-beta.10",
|
||||
"@angular/forms": "8.0.0-beta.10",
|
||||
"@angular/platform-browser": "8.0.0-beta.10",
|
||||
"@angular/animations": "^8.0.0-rc.1",
|
||||
"@angular/common": "^8.0.0-rc.1",
|
||||
"@angular/compiler": "^8.0.0-rc.1",
|
||||
"@angular/core": "^8.0.0-rc.1",
|
||||
"@angular/elements": "^8.0.0-rc.1",
|
||||
"@angular/forms": "^8.0.0-rc.1",
|
||||
"@angular/platform-browser": "^8.0.0-rc.1",
|
||||
"@webcomponents/custom-elements": "^1.1.0",
|
||||
"core-js": "^2.6.1",
|
||||
"material-components-web": "^1.1.0",
|
||||
"rxjs": "^6.4.0",
|
||||
"systemjs": "0.19.43",
|
||||
"tsickle": "^0.34.0",
|
||||
"tsickle": "^0.35.0",
|
||||
"tslib": "^1.9.3",
|
||||
"zone.js": "^0.9.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@angular-devkit/core": "7.3.7",
|
||||
"@angular-devkit/schematics": "7.3.7",
|
||||
"@angular/bazel": "8.0.0-beta.10",
|
||||
"@angular/compiler-cli": "8.0.0-beta.10",
|
||||
"@angular/http": "8.0.0-beta.10",
|
||||
"@angular/platform-browser-dynamic": "8.0.0-beta.10",
|
||||
"@angular/platform-server": "8.0.0-beta.10",
|
||||
"@angular/router": "8.0.0-beta.10",
|
||||
"@angular/upgrade": "8.0.0-beta.10",
|
||||
"@angular-devkit/core": "^8.0.0-rc.1",
|
||||
"@angular-devkit/schematics": "^8.0.0-rc.1",
|
||||
"@angular/bazel": "^8.0.0-rc.1",
|
||||
"@angular/compiler-cli": "^8.0.0-rc.1",
|
||||
"@angular/platform-browser-dynamic": "^8.0.0-rc.1",
|
||||
"@angular/platform-server": "^8.0.0-rc.1",
|
||||
"@angular/router": "^8.0.0-rc.1",
|
||||
"@angular/upgrade": "^8.0.0-rc.1",
|
||||
"@bazel/bazel": "^0.24.1",
|
||||
"@bazel/ibazel": "^0.9.0",
|
||||
"@bazel/jasmine": "0.27.8",
|
||||
"@bazel/karma": "0.27.8",
|
||||
"@bazel/typescript": "0.27.8",
|
||||
"@bazel/typescript": "^0.27.12",
|
||||
"@firebase/app-types": "^0.3.2",
|
||||
"@octokit/rest": "^15.9.4",
|
||||
"@schematics/angular": "7.3.7",
|
||||
"@schematics/angular": "^8.0.0-rc.1",
|
||||
"@types/browser-sync": "^0.0.42",
|
||||
"@types/chalk": "^0.4.31",
|
||||
"@types/fs-extra": "^4.0.3",
|
||||
@@ -135,11 +135,12 @@
|
||||
"selenium-webdriver": "^3.6.0",
|
||||
"sorcery": "^0.10.0",
|
||||
"stylelint": "^9.10.1",
|
||||
"ts-api-guardian": "^0.4.4",
|
||||
"ts-node": "^3.0.4",
|
||||
"tsconfig-paths": "^2.3.0",
|
||||
"tslint": "^5.13.1",
|
||||
"tsutils": "^3.0.0",
|
||||
"typescript": "~3.3.3333",
|
||||
"typescript": "~3.4",
|
||||
"uglify-js": "^2.8.14"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,9 +6,9 @@ describe('CDK ng-add', () => {
|
||||
let runner: SchematicTestRunner;
|
||||
let appTree: Tree;
|
||||
|
||||
beforeEach(() => {
|
||||
beforeEach(async () => {
|
||||
runner = new SchematicTestRunner('schematics', require.resolve('../collection.json'));
|
||||
appTree = createTestApp(runner);
|
||||
appTree = await createTestApp(runner);
|
||||
});
|
||||
|
||||
it('should update the package.json', () => {
|
||||
|
||||
@@ -20,8 +20,8 @@ describe('CDK drag-drop schematic', () => {
|
||||
runner = new SchematicTestRunner('schematics', require.resolve('../../collection.json'));
|
||||
});
|
||||
|
||||
it('should create drag-drop files and add them to module', () => {
|
||||
const tree = runner.runSchematic('drag-drop', baseOptions, createTestApp(runner));
|
||||
it('should create drag-drop files and add them to module', async () => {
|
||||
const tree = runner.runSchematic('drag-drop', baseOptions, await createTestApp(runner));
|
||||
const moduleContent = getFileContent(tree, '/projects/material/src/app/app.module.ts');
|
||||
const files = tree.files;
|
||||
|
||||
@@ -34,23 +34,23 @@ describe('CDK drag-drop schematic', () => {
|
||||
expect(moduleContent).toMatch(/declarations:\s*\[[^\]]+?,\r?\n\s+FooComponent\r?\n/m);
|
||||
});
|
||||
|
||||
it('should add drag-drop module', () => {
|
||||
const tree = runner.runSchematic('drag-drop', baseOptions, createTestApp(runner));
|
||||
it('should add drag-drop module', async () => {
|
||||
const tree = runner.runSchematic('drag-drop', baseOptions, await createTestApp(runner));
|
||||
const moduleContent = getFileContent(tree, '/projects/material/src/app/app.module.ts');
|
||||
|
||||
expect(moduleContent).toContain('DragDropModule');
|
||||
});
|
||||
|
||||
describe('style option', () => {
|
||||
it('should respect the option value', () => {
|
||||
it('should respect the option value', async () => {
|
||||
const tree = runner.runSchematic(
|
||||
'drag-drop', {style: 'scss', ...baseOptions}, createTestApp(runner));
|
||||
'drag-drop', {style: 'scss', ...baseOptions}, await createTestApp(runner));
|
||||
|
||||
expect(tree.files).toContain('/projects/material/src/app/foo/foo.component.scss');
|
||||
});
|
||||
|
||||
it('should respect the deprecated "styleext" option value', () => {
|
||||
let tree = createTestApp(runner);
|
||||
it('should respect the deprecated "styleext" option value', async () => {
|
||||
let tree = await createTestApp(runner);
|
||||
const workspace = getWorkspace(tree);
|
||||
const project = getProjectFromWorkspace(workspace);
|
||||
|
||||
@@ -66,9 +66,9 @@ describe('CDK drag-drop schematic', () => {
|
||||
expect(tree.files).toContain('/projects/material/src/app/foo/foo.component.scss');
|
||||
});
|
||||
|
||||
it('should not generate invalid stylesheets', () => {
|
||||
it('should not generate invalid stylesheets', async () => {
|
||||
const tree = runner.runSchematic(
|
||||
'drag-drop', {style: 'styl', ...baseOptions}, createTestApp(runner));
|
||||
'drag-drop', {style: 'styl', ...baseOptions}, await createTestApp(runner));
|
||||
|
||||
// In this case we expect the schematic to generate a plain "css" file because
|
||||
// the component schematics are using CSS style templates which are not compatible
|
||||
@@ -79,56 +79,56 @@ describe('CDK drag-drop schematic', () => {
|
||||
'Expected the schematic to not generate a "stylus" file');
|
||||
});
|
||||
|
||||
it('should fall back to the @schematics/angular:component option value', () => {
|
||||
it('should fall back to the @schematics/angular:component option value', async () => {
|
||||
const tree = runner.runSchematic(
|
||||
'drag-drop', baseOptions, createTestApp(runner, {style: 'less'}));
|
||||
'drag-drop', baseOptions, await createTestApp(runner, {style: 'less'}));
|
||||
|
||||
expect(tree.files).toContain('/projects/material/src/app/foo/foo.component.less');
|
||||
});
|
||||
});
|
||||
|
||||
describe('inlineStyle option', () => {
|
||||
it('should respect the option value', () => {
|
||||
it('should respect the option value', async () => {
|
||||
const tree = runner.runSchematic(
|
||||
'drag-drop', {inlineStyle: true, ...baseOptions}, createTestApp(runner));
|
||||
'drag-drop', {inlineStyle: true, ...baseOptions}, await createTestApp(runner));
|
||||
|
||||
expect(tree.files).not.toContain('/projects/material/src/app/foo/foo.component.css');
|
||||
});
|
||||
|
||||
it('should fall back to the @schematics/angular:component option value', () => {
|
||||
it('should fall back to the @schematics/angular:component option value', async () => {
|
||||
const tree = runner.runSchematic(
|
||||
'drag-drop', baseOptions, createTestApp(runner, {inlineStyle: true}));
|
||||
'drag-drop', baseOptions, await createTestApp(runner, {inlineStyle: true}));
|
||||
|
||||
expect(tree.files).not.toContain('/projects/material/src/app/foo/foo.component.css');
|
||||
});
|
||||
});
|
||||
|
||||
describe('inlineTemplate option', () => {
|
||||
it('should respect the option value', () => {
|
||||
it('should respect the option value', async () => {
|
||||
const tree = runner.runSchematic(
|
||||
'drag-drop', {inlineTemplate: true, ...baseOptions}, createTestApp(runner));
|
||||
'drag-drop', {inlineTemplate: true, ...baseOptions}, await createTestApp(runner));
|
||||
|
||||
expect(tree.files).not.toContain('/projects/material/src/app/foo/foo.component.html');
|
||||
});
|
||||
|
||||
it('should fall back to the @schematics/angular:component option value', () => {
|
||||
it('should fall back to the @schematics/angular:component option value', async () => {
|
||||
const tree = runner.runSchematic(
|
||||
'drag-drop', baseOptions, createTestApp(runner, {inlineTemplate: true}));
|
||||
'drag-drop', baseOptions, await createTestApp(runner, {inlineTemplate: true}));
|
||||
|
||||
expect(tree.files).not.toContain('/projects/material/src/app/foo/foo.component.html');
|
||||
});
|
||||
});
|
||||
|
||||
describe('skipTests option', () => {
|
||||
it('should respect the option value', () => {
|
||||
it('should respect the option value', async () => {
|
||||
const tree = runner.runSchematic(
|
||||
'drag-drop', {skipTests: true, ...baseOptions}, createTestApp(runner));
|
||||
'drag-drop', {skipTests: true, ...baseOptions}, await createTestApp(runner));
|
||||
|
||||
expect(tree.files).not.toContain('/projects/material/src/app/foo/foo.component.spec.ts');
|
||||
});
|
||||
|
||||
it('should respect the deprecated global "spec" option value', () => {
|
||||
let tree = createTestApp(runner);
|
||||
it('should respect the deprecated global "spec" option value', async () => {
|
||||
let tree = await createTestApp(runner);
|
||||
const workspace = getWorkspace(tree);
|
||||
const project = getProjectFromWorkspace(workspace);
|
||||
|
||||
@@ -144,9 +144,9 @@ describe('CDK drag-drop schematic', () => {
|
||||
expect(tree.files).not.toContain('/projects/material/src/app/foo/foo.component.spec.ts');
|
||||
});
|
||||
|
||||
it('should fall back to the @schematics/angular:component option value', () => {
|
||||
it('should fall back to the @schematics/angular:component option value', async () => {
|
||||
const tree = runner.runSchematic(
|
||||
'drag-drop', baseOptions, createTestApp(runner, {skipTests: true}));
|
||||
'drag-drop', baseOptions, await createTestApp(runner, {skipTests: true}));
|
||||
|
||||
expect(tree.files).not.toContain('/projects/material/src/app/foo/foo.component.spec.ts');
|
||||
});
|
||||
|
||||
@@ -4,8 +4,8 @@ import {createTestCaseSetup} from '../../../testing';
|
||||
describe('v6 method call checks', () => {
|
||||
|
||||
it('should properly report invalid method calls', async () => {
|
||||
const {runFixers, removeTempDir} = createTestCaseSetup('migration-v6', migrationCollection,
|
||||
[require.resolve('./method-call-checks_input.ts')]);
|
||||
const {runFixers, removeTempDir} = await createTestCaseSetup('migration-v6',
|
||||
migrationCollection, [require.resolve('./method-call-checks_input.ts')]);
|
||||
|
||||
const {logOutput} = await runFixers();
|
||||
|
||||
|
||||
@@ -9,13 +9,14 @@
|
||||
import {SchematicTestRunner, UnitTestTree} from '@angular-devkit/schematics/testing';
|
||||
|
||||
/** Create a base app used for testing. */
|
||||
export function createTestApp(runner: SchematicTestRunner, appOptions = {}): UnitTestTree {
|
||||
export async function createTestApp(runner: SchematicTestRunner, appOptions = {}):
|
||||
Promise<UnitTestTree> {
|
||||
const workspaceTree = runner.runExternalSchematic('@schematics/angular', 'workspace', {
|
||||
name: 'workspace',
|
||||
version: '6.0.0',
|
||||
newProjectRoot: 'projects',
|
||||
});
|
||||
|
||||
return runner.runExternalSchematic('@schematics/angular', 'application',
|
||||
{name: 'material', ...appOptions}, workspaceTree);
|
||||
return runner.runExternalSchematicAsync('@schematics/angular', 'application',
|
||||
{name: 'material', ...appOptions}, workspaceTree).toPromise();
|
||||
}
|
||||
|
||||
@@ -30,9 +30,9 @@ export function readFileContent(filePath: string): string {
|
||||
* Creates a test app schematic tree that will be copied over to a real filesystem location.
|
||||
* This is necessary because TSLint is not able to read from the virtual filesystem tree.
|
||||
*/
|
||||
export function createFileSystemTestApp(runner: SchematicTestRunner) {
|
||||
export async function createFileSystemTestApp(runner: SchematicTestRunner) {
|
||||
const tempFileSystemHost = new TempScopedNodeJsSyncHost();
|
||||
const appTree: UnitTestTree = createTestApp(runner, {name: 'cdk-testing'});
|
||||
const appTree: UnitTestTree = await createTestApp(runner, {name: 'cdk-testing'});
|
||||
const tempPath = getSystemPath(tempFileSystemHost.root);
|
||||
|
||||
// Since the TSLint fix task expects all files to be present on the real file system, we
|
||||
@@ -44,7 +44,7 @@ export function createFileSystemTestApp(runner: SchematicTestRunner) {
|
||||
return {appTree, tempPath, removeTempDir: () => removeSync(tempPath)};
|
||||
}
|
||||
|
||||
export function createTestCaseSetup(migrationName: string, collectionPath: string,
|
||||
export async function createTestCaseSetup(migrationName: string, collectionPath: string,
|
||||
inputFiles: string[]) {
|
||||
|
||||
const runner = new SchematicTestRunner('schematics', collectionPath);
|
||||
@@ -53,7 +53,7 @@ export function createTestCaseSetup(migrationName: string, collectionPath: strin
|
||||
let logOutput = '';
|
||||
runner.logger.subscribe(entry => logOutput += entry.message);
|
||||
|
||||
const {appTree, tempPath, removeTempDir} = createFileSystemTestApp(runner);
|
||||
const {appTree, tempPath, removeTempDir} = await createFileSystemTestApp(runner);
|
||||
|
||||
// Write each test-case input to the file-system. This is necessary because otherwise
|
||||
// TSLint won't be able to pick up the test cases.
|
||||
@@ -66,7 +66,7 @@ export function createTestCaseSetup(migrationName: string, collectionPath: strin
|
||||
});
|
||||
|
||||
const runFixers = async function() {
|
||||
runner.runSchematic(migrationName, {}, appTree);
|
||||
await runner.runSchematicAsync(migrationName, {}, appTree).toPromise();
|
||||
|
||||
// Switch to the new temporary directory because otherwise TSLint cannot read the files.
|
||||
process.chdir(tempPath);
|
||||
@@ -149,7 +149,7 @@ export function defineJasmineTestCases(versionName: string, collectionFile: stri
|
||||
|
||||
beforeAll(async () => {
|
||||
const {tempPath, runFixers, removeTempDir} =
|
||||
createTestCaseSetup(`migration-${versionName}`, collectionFile, inputFiles);
|
||||
await createTestCaseSetup(`migration-${versionName}`, collectionFile, inputFiles);
|
||||
|
||||
await runFixers();
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
* found in the LICENSE file at https://angular.io/license
|
||||
*/
|
||||
|
||||
import {WorkspaceProject} from '@angular-devkit/core/src/workspace';
|
||||
import {WorkspaceProject} from '@angular-devkit/core/src/experimental/workspace';
|
||||
import {SchematicsException, Tree} from '@angular-devkit/schematics';
|
||||
import {Schema as ComponentOptions} from '@schematics/angular/component/schema';
|
||||
import {addImportToModule} from '@schematics/angular/utility/ast-utils';
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
* found in the LICENSE file at https://angular.io/license
|
||||
*/
|
||||
|
||||
import {WorkspaceSchema, WorkspaceProject} from '@angular-devkit/core/src/workspace';
|
||||
import {WorkspaceSchema, WorkspaceProject} from '@angular-devkit/core/src/experimental/workspace';
|
||||
import {SchematicsException} from '@angular-devkit/schematics';
|
||||
|
||||
/**
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
* found in the LICENSE file at https://angular.io/license
|
||||
*/
|
||||
|
||||
import {WorkspaceProject} from '@angular-devkit/core/src/workspace';
|
||||
import {WorkspaceProject} from '@angular-devkit/core/src/experimental/workspace';
|
||||
import {SchematicsException} from '@angular-devkit/schematics';
|
||||
import {getProjectTargetOptions} from './project-targets';
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
*/
|
||||
|
||||
import {normalize} from '@angular-devkit/core';
|
||||
import {WorkspaceProject} from '@angular-devkit/core/src/workspace';
|
||||
import {WorkspaceProject} from '@angular-devkit/core/src/experimental/workspace';
|
||||
import {getProjectTargetOptions} from './project-targets';
|
||||
|
||||
/** Regular expression that matches all possible Angular CLI default style files. */
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
* found in the LICENSE file at https://angular.io/license
|
||||
*/
|
||||
|
||||
import {WorkspaceProject} from '@angular-devkit/core/src/workspace';
|
||||
import {WorkspaceProject} from '@angular-devkit/core/src/experimental/workspace';
|
||||
import {SchematicsException} from '@angular-devkit/schematics';
|
||||
|
||||
/** Resolves the architect options for the build target of the given project. */
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
* found in the LICENSE file at https://angular.io/license
|
||||
*/
|
||||
|
||||
import {WorkspaceProject} from '@angular-devkit/core/src/workspace';
|
||||
import {WorkspaceProject} from '@angular-devkit/core/src/experimental/workspace';
|
||||
|
||||
|
||||
/**
|
||||
|
||||
@@ -70,6 +70,8 @@ ts_devserver(
|
||||
"@npm//zone.js",
|
||||
"@npm//core-js",
|
||||
"@npm//hammerjs",
|
||||
"@npm//material-components-web",
|
||||
"@npm//moment",
|
||||
"@npm//@webcomponents/custom-elements",
|
||||
"//src/material/prebuilt-themes:indigo-pink",
|
||||
":index.html",
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
* found in the LICENSE file at https://angular.io/license
|
||||
*/
|
||||
|
||||
import {WorkspaceProject} from '@angular-devkit/core/src/workspace';
|
||||
import {WorkspaceProject} from '@angular-devkit/core/src/experimental/workspace';
|
||||
import {SchematicsException} from '@angular-devkit/schematics';
|
||||
import {getProjectTargetOptions} from '@angular/cdk/schematics';
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import {normalize} from '@angular-devkit/core';
|
||||
import {WorkspaceProject} from '@angular-devkit/core/src/workspace';
|
||||
import {WorkspaceProject} from '@angular-devkit/core/src/experimental/workspace';
|
||||
import {Tree} from '@angular-devkit/schematics';
|
||||
import {SchematicTestRunner} from '@angular-devkit/schematics/testing';
|
||||
import {
|
||||
@@ -16,9 +16,9 @@ describe('ng-add schematic', () => {
|
||||
let runner: SchematicTestRunner;
|
||||
let appTree: Tree;
|
||||
|
||||
beforeEach(() => {
|
||||
beforeEach(async () => {
|
||||
runner = new SchematicTestRunner('schematics', require.resolve('../collection.json'));
|
||||
appTree = createTestApp(runner);
|
||||
appTree = await createTestApp(runner);
|
||||
});
|
||||
|
||||
/** Expects the given file to be in the styles of the specified workspace project. */
|
||||
@@ -77,9 +77,9 @@ describe('ng-add schematic', () => {
|
||||
'./node_modules/@angular/material/prebuilt-themes/indigo-pink.css');
|
||||
});
|
||||
|
||||
it('should support adding a custom theme', () => {
|
||||
it('should support adding a custom theme', async () => {
|
||||
// TODO(devversion): do not re-create test app here.
|
||||
appTree = createTestApp(runner, {style: 'scss'});
|
||||
appTree = await createTestApp(runner, {style: 'scss'});
|
||||
|
||||
const tree = runner.runSchematic('ng-add-setup-project', {theme: 'custom'}, appTree);
|
||||
|
||||
@@ -94,9 +94,9 @@ describe('ng-add schematic', () => {
|
||||
expect(themeContent).toContain(`$app-primary: mat-palette(`);
|
||||
});
|
||||
|
||||
it('should create a custom theme file if no SCSS file could be found', () => {
|
||||
it('should create a custom theme file if no SCSS file could be found', async () => {
|
||||
// TODO(devversion): do not re-create test app here.
|
||||
appTree = createTestApp(runner, {style: 'css'});
|
||||
appTree = await createTestApp(runner, {style: 'css'});
|
||||
|
||||
const tree = runner.runSchematic('ng-add-setup-project', {theme: 'custom'}, appTree);
|
||||
const workspace = getWorkspace(tree);
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
*/
|
||||
|
||||
import {normalize} from '@angular-devkit/core';
|
||||
import {WorkspaceProject, WorkspaceSchema} from '@angular-devkit/core/src/workspace';
|
||||
import {WorkspaceProject, WorkspaceSchema} from '@angular-devkit/core/src/experimental/workspace';
|
||||
import {SchematicsException, Tree} from '@angular-devkit/schematics';
|
||||
import {
|
||||
getProjectFromWorkspace,
|
||||
|
||||
@@ -14,8 +14,8 @@ describe('Material address-form schematic', () => {
|
||||
runner = new SchematicTestRunner('schematics', require.resolve('../../collection.json'));
|
||||
});
|
||||
|
||||
it('should create address-form files and add them to module', () => {
|
||||
const tree = runner.runSchematic('address-form', baseOptions, createTestApp(runner));
|
||||
it('should create address-form files and add them to module', async () => {
|
||||
const tree = runner.runSchematic('address-form', baseOptions, await createTestApp(runner));
|
||||
const files = tree.files;
|
||||
|
||||
expect(files).toContain('/projects/material/src/app/foo/foo.component.css');
|
||||
@@ -28,8 +28,8 @@ describe('Material address-form schematic', () => {
|
||||
expect(moduleContent).toMatch(/declarations:\s*\[[^\]]+?,\r?\n\s+FooComponent\r?\n/m);
|
||||
});
|
||||
|
||||
it('should add address-form imports to module', () => {
|
||||
const tree = runner.runSchematic('address-form', baseOptions, createTestApp(runner));
|
||||
it('should add address-form imports to module', async () => {
|
||||
const tree = runner.runSchematic('address-form', baseOptions, await createTestApp(runner));
|
||||
const moduleContent = getFileContent(tree, '/projects/material/src/app/app.module.ts');
|
||||
|
||||
expect(moduleContent).toContain('MatInputModule');
|
||||
@@ -39,71 +39,72 @@ describe('Material address-form schematic', () => {
|
||||
expect(moduleContent).toContain('ReactiveFormsModule');
|
||||
});
|
||||
|
||||
it('should throw if no name has been specified', () => {
|
||||
it('should throw if no name has been specified', async () => {
|
||||
const appTree = await createTestApp(runner);
|
||||
expect(() => {
|
||||
runner.runSchematic('address-form', {project: 'material'}, createTestApp(runner));
|
||||
runner.runSchematic('address-form', {project: 'material'}, appTree);
|
||||
}).toThrowError(/required property 'name'/);
|
||||
});
|
||||
|
||||
describe('style option', () => {
|
||||
it('should respect the option value', () => {
|
||||
it('should respect the option value', async () => {
|
||||
const tree = runner.runSchematic(
|
||||
'address-form', {style: 'scss', ...baseOptions}, createTestApp(runner));
|
||||
'address-form', {style: 'scss', ...baseOptions}, await createTestApp(runner));
|
||||
|
||||
expect(tree.files).toContain('/projects/material/src/app/foo/foo.component.scss');
|
||||
});
|
||||
|
||||
it('should fall back to the @schematics/angular:component option value', () => {
|
||||
it('should fall back to the @schematics/angular:component option value', async () => {
|
||||
const tree = runner.runSchematic(
|
||||
'address-form', baseOptions, createTestApp(runner, {style: 'less'}));
|
||||
'address-form', baseOptions, await createTestApp(runner, {style: 'less'}));
|
||||
|
||||
expect(tree.files).toContain('/projects/material/src/app/foo/foo.component.less');
|
||||
});
|
||||
});
|
||||
|
||||
describe('inlineStyle option', () => {
|
||||
it('should respect the option value', () => {
|
||||
it('should respect the option value', async () => {
|
||||
const tree = runner.runSchematic(
|
||||
'address-form', {inlineStyle: true, ...baseOptions}, createTestApp(runner));
|
||||
'address-form', {inlineStyle: true, ...baseOptions}, await createTestApp(runner));
|
||||
|
||||
expect(tree.files).not.toContain('/projects/material/src/app/foo/foo.component.css');
|
||||
});
|
||||
|
||||
it('should fall back to the @schematics/angular:component option value', () => {
|
||||
it('should fall back to the @schematics/angular:component option value', async () => {
|
||||
const tree = runner.runSchematic(
|
||||
'address-form', baseOptions, createTestApp(runner, {inlineStyle: true}));
|
||||
'address-form', baseOptions, await createTestApp(runner, {inlineStyle: true}));
|
||||
|
||||
expect(tree.files).not.toContain('/projects/material/src/app/foo/foo.component.css');
|
||||
});
|
||||
});
|
||||
|
||||
describe('inlineTemplate option', () => {
|
||||
it('should respect the option value', () => {
|
||||
it('should respect the option value', async () => {
|
||||
const tree = runner.runSchematic(
|
||||
'address-form', {inlineTemplate: true, ...baseOptions}, createTestApp(runner));
|
||||
'address-form', {inlineTemplate: true, ...baseOptions}, await createTestApp(runner));
|
||||
|
||||
expect(tree.files).not.toContain('/projects/material/src/app/foo/foo.component.html');
|
||||
});
|
||||
|
||||
it('should fall back to the @schematics/angular:component option value', () => {
|
||||
it('should fall back to the @schematics/angular:component option value', async () => {
|
||||
const tree = runner.runSchematic(
|
||||
'address-form', baseOptions, createTestApp(runner, {inlineTemplate: true}));
|
||||
'address-form', baseOptions, await createTestApp(runner, {inlineTemplate: true}));
|
||||
|
||||
expect(tree.files).not.toContain('/projects/material/src/app/foo/foo.component.html');
|
||||
});
|
||||
});
|
||||
|
||||
describe('skipTests option', () => {
|
||||
it('should respect the option value', () => {
|
||||
it('should respect the option value', async () => {
|
||||
const tree = runner.runSchematic(
|
||||
'address-form', {skipTests: true, ...baseOptions}, createTestApp(runner));
|
||||
'address-form', {skipTests: true, ...baseOptions}, await createTestApp(runner));
|
||||
|
||||
expect(tree.files).not.toContain('/projects/material/src/app/foo/foo.component.spec.ts');
|
||||
});
|
||||
|
||||
it('should fall back to the @schematics/angular:component option value', () => {
|
||||
it('should fall back to the @schematics/angular:component option value', async () => {
|
||||
const tree = runner.runSchematic(
|
||||
'address-form', baseOptions, createTestApp(runner, {skipTests: true}));
|
||||
'address-form', baseOptions, await createTestApp(runner, {skipTests: true}));
|
||||
|
||||
expect(tree.files).not.toContain('/projects/material/src/app/foo/foo.component.spec.ts');
|
||||
});
|
||||
|
||||
@@ -14,8 +14,8 @@ describe('material-dashboard-schematic', () => {
|
||||
runner = new SchematicTestRunner('schematics', require.resolve('../../collection.json'));
|
||||
});
|
||||
|
||||
it('should create dashboard files and add them to module', () => {
|
||||
const tree = runner.runSchematic('dashboard', baseOptions, createTestApp(runner));
|
||||
it('should create dashboard files and add them to module', async () => {
|
||||
const tree = runner.runSchematic('dashboard', baseOptions, await createTestApp(runner));
|
||||
const files = tree.files;
|
||||
|
||||
expect(files).toContain('/projects/material/src/app/foo/foo.component.css');
|
||||
@@ -28,8 +28,8 @@ describe('material-dashboard-schematic', () => {
|
||||
expect(moduleContent).toMatch(/declarations:\s*\[[^\]]+?,\r?\n\s+FooComponent\r?\n/m);
|
||||
});
|
||||
|
||||
it('should add dashboard imports to module', () => {
|
||||
const tree = runner.runSchematic('dashboard', baseOptions, createTestApp(runner));
|
||||
it('should add dashboard imports to module', async () => {
|
||||
const tree = runner.runSchematic('dashboard', baseOptions, await createTestApp(runner));
|
||||
const moduleContent = getFileContent(tree, '/projects/material/src/app/app.module.ts');
|
||||
|
||||
expect(moduleContent).toContain('MatGridListModule');
|
||||
@@ -43,71 +43,72 @@ describe('material-dashboard-schematic', () => {
|
||||
` from '@angular/material';`);
|
||||
});
|
||||
|
||||
it('should throw if no name has been specified', () => {
|
||||
it('should throw if no name has been specified', async () => {
|
||||
const appTree = await createTestApp(runner);
|
||||
expect(() => {
|
||||
runner.runSchematic('dashboard', {project: 'material'}, createTestApp(runner));
|
||||
runner.runSchematic('dashboard', {project: 'material'}, appTree);
|
||||
}).toThrowError(/required property 'name'/);
|
||||
});
|
||||
|
||||
describe('style option', () => {
|
||||
it('should respect the option value', () => {
|
||||
it('should respect the option value', async () => {
|
||||
const tree = runner.runSchematic(
|
||||
'dashboard', {style: 'scss', ...baseOptions}, createTestApp(runner));
|
||||
'dashboard', {style: 'scss', ...baseOptions}, await createTestApp(runner));
|
||||
|
||||
expect(tree.files).toContain('/projects/material/src/app/foo/foo.component.scss');
|
||||
});
|
||||
|
||||
it('should fall back to the @schematics/angular:component option value', () => {
|
||||
it('should fall back to the @schematics/angular:component option value', async () => {
|
||||
const tree = runner.runSchematic(
|
||||
'dashboard', baseOptions, createTestApp(runner, {style: 'less'}));
|
||||
'dashboard', baseOptions, await createTestApp(runner, {style: 'less'}));
|
||||
|
||||
expect(tree.files).toContain('/projects/material/src/app/foo/foo.component.less');
|
||||
});
|
||||
});
|
||||
|
||||
describe('inlineStyle option', () => {
|
||||
it('should respect the option value', () => {
|
||||
it('should respect the option value', async () => {
|
||||
const tree = runner.runSchematic(
|
||||
'dashboard', {inlineStyle: true, ...baseOptions}, createTestApp(runner));
|
||||
'dashboard', {inlineStyle: true, ...baseOptions}, await createTestApp(runner));
|
||||
|
||||
expect(tree.files).not.toContain('/projects/material/src/app/foo/foo.component.css');
|
||||
});
|
||||
|
||||
it('should fall back to the @schematics/angular:component option value', () => {
|
||||
it('should fall back to the @schematics/angular:component option value', async () => {
|
||||
const tree = runner.runSchematic(
|
||||
'dashboard', baseOptions, createTestApp(runner, {inlineStyle: true}));
|
||||
'dashboard', baseOptions, await createTestApp(runner, {inlineStyle: true}));
|
||||
|
||||
expect(tree.files).not.toContain('/projects/material/src/app/foo/foo.component.css');
|
||||
});
|
||||
});
|
||||
|
||||
describe('inlineTemplate option', () => {
|
||||
it('should respect the option value', () => {
|
||||
it('should respect the option value', async () => {
|
||||
const tree = runner.runSchematic(
|
||||
'dashboard', {inlineTemplate: true, ...baseOptions}, createTestApp(runner));
|
||||
'dashboard', {inlineTemplate: true, ...baseOptions}, await createTestApp(runner));
|
||||
|
||||
expect(tree.files).not.toContain('/projects/material/src/app/foo/foo.component.html');
|
||||
});
|
||||
|
||||
it('should fall back to the @schematics/angular:component option value', () => {
|
||||
it('should fall back to the @schematics/angular:component option value', async () => {
|
||||
const tree = runner.runSchematic(
|
||||
'dashboard', baseOptions, createTestApp(runner, {inlineTemplate: true}));
|
||||
'dashboard', baseOptions, await createTestApp(runner, {inlineTemplate: true}));
|
||||
|
||||
expect(tree.files).not.toContain('/projects/material/src/app/foo/foo.component.html');
|
||||
});
|
||||
});
|
||||
|
||||
describe('skipTests option', () => {
|
||||
it('should respect the option value', () => {
|
||||
it('should respect the option value', async () => {
|
||||
const tree = runner.runSchematic(
|
||||
'dashboard', {skipTests: true, ...baseOptions}, createTestApp(runner));
|
||||
'dashboard', {skipTests: true, ...baseOptions}, await createTestApp(runner));
|
||||
|
||||
expect(tree.files).not.toContain('/projects/material/src/app/foo/foo.component.spec.ts');
|
||||
});
|
||||
|
||||
it('should fall back to the @schematics/angular:component option value', () => {
|
||||
it('should fall back to the @schematics/angular:component option value', async () => {
|
||||
const tree = runner.runSchematic(
|
||||
'dashboard', baseOptions, createTestApp(runner, {skipTests: true}));
|
||||
'dashboard', baseOptions, await createTestApp(runner, {skipTests: true}));
|
||||
|
||||
expect(tree.files).not.toContain('/projects/material/src/app/foo/foo.component.spec.ts');
|
||||
});
|
||||
|
||||
@@ -14,8 +14,8 @@ describe('material-nav-schematic', () => {
|
||||
runner = new SchematicTestRunner('schematics', require.resolve('../../collection.json'));
|
||||
});
|
||||
|
||||
it('should create nav files and add them to module', () => {
|
||||
const tree = runner.runSchematic('nav', baseOptions, createTestApp(runner));
|
||||
it('should create nav files and add them to module', async () => {
|
||||
const tree = runner.runSchematic('nav', baseOptions, await createTestApp(runner));
|
||||
const files = tree.files;
|
||||
|
||||
expect(files).toContain('/projects/material/src/app/foo/foo.component.css');
|
||||
@@ -28,8 +28,8 @@ describe('material-nav-schematic', () => {
|
||||
expect(moduleContent).toMatch(/declarations:\s*\[[^\]]+?,\r?\n\s+FooComponent\r?\n/m);
|
||||
});
|
||||
|
||||
it('should add nav imports to module', () => {
|
||||
const tree = runner.runSchematic('nav', baseOptions, createTestApp(runner));
|
||||
it('should add nav imports to module', async () => {
|
||||
const tree = runner.runSchematic('nav', baseOptions, await createTestApp(runner));
|
||||
const moduleContent = getFileContent(tree, '/projects/material/src/app/app.module.ts');
|
||||
|
||||
expect(moduleContent).toContain('LayoutModule');
|
||||
@@ -45,71 +45,72 @@ describe('material-nav-schematic', () => {
|
||||
`MatListModule } from '@angular/material';`);
|
||||
});
|
||||
|
||||
it('should throw if no name has been specified', () => {
|
||||
it('should throw if no name has been specified', async () => {
|
||||
const appTree = await createTestApp(runner);
|
||||
expect(() => {
|
||||
runner.runSchematic('nav', {project: 'material'}, createTestApp(runner));
|
||||
runner.runSchematic('nav', {project: 'material'}, appTree);
|
||||
}).toThrowError(/required property 'name'/);
|
||||
});
|
||||
|
||||
describe('style option', () => {
|
||||
it('should respect the option value', () => {
|
||||
it('should respect the option value', async () => {
|
||||
const tree = runner.runSchematic(
|
||||
'nav', {style: 'scss', ...baseOptions}, createTestApp(runner));
|
||||
'nav', {style: 'scss', ...baseOptions}, await createTestApp(runner));
|
||||
|
||||
expect(tree.files).toContain('/projects/material/src/app/foo/foo.component.scss');
|
||||
});
|
||||
|
||||
it('should fall back to the @schematics/angular:component option value', () => {
|
||||
it('should fall back to the @schematics/angular:component option value', async () => {
|
||||
const tree = runner.runSchematic(
|
||||
'nav', baseOptions, createTestApp(runner, {style: 'less'}));
|
||||
'nav', baseOptions, await createTestApp(runner, {style: 'less'}));
|
||||
|
||||
expect(tree.files).toContain('/projects/material/src/app/foo/foo.component.less');
|
||||
});
|
||||
});
|
||||
|
||||
describe('inlineStyle option', () => {
|
||||
it('should respect the option value', () => {
|
||||
it('should respect the option value', async () => {
|
||||
const tree = runner.runSchematic(
|
||||
'nav', {inlineStyle: true, ...baseOptions}, createTestApp(runner));
|
||||
'nav', {inlineStyle: true, ...baseOptions}, await createTestApp(runner));
|
||||
|
||||
expect(tree.files).not.toContain('/projects/material/src/app/foo/foo.component.css');
|
||||
});
|
||||
|
||||
it('should fall back to the @schematics/angular:component option value', () => {
|
||||
it('should fall back to the @schematics/angular:component option value', async () => {
|
||||
const tree = runner.runSchematic(
|
||||
'nav', baseOptions, createTestApp(runner, {inlineStyle: true}));
|
||||
'nav', baseOptions, await createTestApp(runner, {inlineStyle: true}));
|
||||
|
||||
expect(tree.files).not.toContain('/projects/material/src/app/foo/foo.component.css');
|
||||
});
|
||||
});
|
||||
|
||||
describe('inlineTemplate option', () => {
|
||||
it('should respect the option value', () => {
|
||||
it('should respect the option value', async () => {
|
||||
const tree = runner.runSchematic(
|
||||
'nav', {inlineTemplate: true, ...baseOptions}, createTestApp(runner));
|
||||
'nav', {inlineTemplate: true, ...baseOptions}, await createTestApp(runner));
|
||||
|
||||
expect(tree.files).not.toContain('/projects/material/src/app/foo/foo.component.html');
|
||||
});
|
||||
|
||||
it('should fall back to the @schematics/angular:component option value', () => {
|
||||
it('should fall back to the @schematics/angular:component option value', async () => {
|
||||
const tree = runner.runSchematic(
|
||||
'nav', baseOptions, createTestApp(runner, {inlineTemplate: true}));
|
||||
'nav', baseOptions, await createTestApp(runner, {inlineTemplate: true}));
|
||||
|
||||
expect(tree.files).not.toContain('/projects/material/src/app/foo/foo.component.html');
|
||||
});
|
||||
});
|
||||
|
||||
describe('skipTests option', () => {
|
||||
it('should respect the option value', () => {
|
||||
it('should respect the option value', async () => {
|
||||
const tree = runner.runSchematic(
|
||||
'nav', {skipTests: true, ...baseOptions}, createTestApp(runner));
|
||||
'nav', {skipTests: true, ...baseOptions}, await createTestApp(runner));
|
||||
|
||||
expect(tree.files).not.toContain('/projects/material/src/app/foo/foo.component.spec.ts');
|
||||
});
|
||||
|
||||
it('should fall back to the @schematics/angular:component option value', () => {
|
||||
it('should fall back to the @schematics/angular:component option value', async () => {
|
||||
const tree = runner.runSchematic(
|
||||
'nav', baseOptions, createTestApp(runner, {skipTests: true}));
|
||||
'nav', baseOptions, await createTestApp(runner, {skipTests: true}));
|
||||
|
||||
expect(tree.files).not.toContain('/projects/material/src/app/foo/foo.component.spec.ts');
|
||||
});
|
||||
|
||||
@@ -14,8 +14,8 @@ describe('material-table-schematic', () => {
|
||||
runner = new SchematicTestRunner('schematics', require.resolve('../../collection.json'));
|
||||
});
|
||||
|
||||
it('should create table files and add them to module', () => {
|
||||
const tree = runner.runSchematic('table', baseOptions, createTestApp(runner));
|
||||
it('should create table files and add them to module', async () => {
|
||||
const tree = runner.runSchematic('table', baseOptions, await createTestApp(runner));
|
||||
const files = tree.files;
|
||||
|
||||
expect(files).toContain('/projects/material/src/app/foo/foo.component.css');
|
||||
@@ -40,8 +40,8 @@ describe('material-table-schematic', () => {
|
||||
expect(componentContent).toContain('FooDataSource');
|
||||
});
|
||||
|
||||
it('should add table imports to module', () => {
|
||||
const tree = runner.runSchematic('table', baseOptions, createTestApp(runner));
|
||||
it('should add table imports to module', async () => {
|
||||
const tree = runner.runSchematic('table', baseOptions, await createTestApp(runner));
|
||||
const moduleContent = getFileContent(tree, '/projects/material/src/app/app.module.ts');
|
||||
|
||||
expect(moduleContent).toContain('MatTableModule');
|
||||
@@ -52,71 +52,72 @@ describe('material-table-schematic', () => {
|
||||
`import { MatTableModule, MatPaginatorModule, MatSortModule } from '@angular/material';`);
|
||||
});
|
||||
|
||||
it('should throw if no name has been specified', () => {
|
||||
it('should throw if no name has been specified', async () => {
|
||||
const appTree = await createTestApp(runner);
|
||||
expect(() => {
|
||||
runner.runSchematic('table', {project: 'material'}, createTestApp(runner));
|
||||
runner.runSchematic('table', {project: 'material'}, appTree);
|
||||
}).toThrowError(/required property 'name'/);
|
||||
});
|
||||
|
||||
describe('style option', () => {
|
||||
it('should respect the option value', () => {
|
||||
it('should respect the option value', async () => {
|
||||
const tree = runner.runSchematic(
|
||||
'table', {style: 'scss', ...baseOptions}, createTestApp(runner));
|
||||
'table', {style: 'scss', ...baseOptions}, await createTestApp(runner));
|
||||
|
||||
expect(tree.files).toContain('/projects/material/src/app/foo/foo.component.scss');
|
||||
});
|
||||
|
||||
it('should fall back to the @schematics/angular:component option value', () => {
|
||||
it('should fall back to the @schematics/angular:component option value', async () => {
|
||||
const tree = runner.runSchematic(
|
||||
'table', baseOptions, createTestApp(runner, {style: 'less'}));
|
||||
'table', baseOptions, await createTestApp(runner, {style: 'less'}));
|
||||
|
||||
expect(tree.files).toContain('/projects/material/src/app/foo/foo.component.less');
|
||||
});
|
||||
});
|
||||
|
||||
describe('inlineStyle option', () => {
|
||||
it('should respect the option value', () => {
|
||||
it('should respect the option value', async () => {
|
||||
const tree = runner.runSchematic(
|
||||
'table', {inlineStyle: true, ...baseOptions}, createTestApp(runner));
|
||||
'table', {inlineStyle: true, ...baseOptions}, await createTestApp(runner));
|
||||
|
||||
expect(tree.files).not.toContain('/projects/material/src/app/foo/foo.component.css');
|
||||
});
|
||||
|
||||
it('should fall back to the @schematics/angular:component option value', () => {
|
||||
it('should fall back to the @schematics/angular:component option value', async () => {
|
||||
const tree = runner.runSchematic(
|
||||
'table', baseOptions, createTestApp(runner, {inlineStyle: true}));
|
||||
'table', baseOptions, await createTestApp(runner, {inlineStyle: true}));
|
||||
|
||||
expect(tree.files).not.toContain('/projects/material/src/app/foo/foo.component.css');
|
||||
});
|
||||
});
|
||||
|
||||
describe('inlineTemplate option', () => {
|
||||
it('should respect the option value', () => {
|
||||
it('should respect the option value', async () => {
|
||||
const tree = runner.runSchematic(
|
||||
'table', {inlineTemplate: true, ...baseOptions}, createTestApp(runner));
|
||||
'table', {inlineTemplate: true, ...baseOptions}, await createTestApp(runner));
|
||||
|
||||
expect(tree.files).not.toContain('/projects/material/src/app/foo/foo.component.html');
|
||||
});
|
||||
|
||||
it('should fall back to the @schematics/angular:component option value', () => {
|
||||
it('should fall back to the @schematics/angular:component option value', async () => {
|
||||
const tree = runner.runSchematic(
|
||||
'table', baseOptions, createTestApp(runner, {inlineTemplate: true}));
|
||||
'table', baseOptions, await createTestApp(runner, {inlineTemplate: true}));
|
||||
|
||||
expect(tree.files).not.toContain('/projects/material/src/app/foo/foo.component.html');
|
||||
});
|
||||
});
|
||||
|
||||
describe('skipTests option', () => {
|
||||
it('should respect the option value', () => {
|
||||
it('should respect the option value', async () => {
|
||||
const tree = runner.runSchematic(
|
||||
'table', {skipTests: true, ...baseOptions}, createTestApp(runner));
|
||||
'table', {skipTests: true, ...baseOptions}, await createTestApp(runner));
|
||||
|
||||
expect(tree.files).not.toContain('/projects/material/src/app/foo/foo.component.spec.ts');
|
||||
});
|
||||
|
||||
it('should fall back to the @schematics/angular:component option value', () => {
|
||||
it('should fall back to the @schematics/angular:component option value', async () => {
|
||||
const tree = runner.runSchematic(
|
||||
'table', baseOptions, createTestApp(runner, {skipTests: true}));
|
||||
'table', baseOptions, await createTestApp(runner, {skipTests: true}));
|
||||
|
||||
expect(tree.files).not.toContain('/projects/material/src/app/foo/foo.component.spec.ts');
|
||||
});
|
||||
|
||||
@@ -14,8 +14,8 @@ describe('Material tree schematic', () => {
|
||||
runner = new SchematicTestRunner('schematics', require.resolve('../../collection.json'));
|
||||
});
|
||||
|
||||
it('should create tree component files and add them to module', () => {
|
||||
const tree = runner.runSchematic('tree', baseOptions, createTestApp(runner));
|
||||
it('should create tree component files and add them to module', async () => {
|
||||
const tree = runner.runSchematic('tree', baseOptions, await createTestApp(runner));
|
||||
const files = tree.files;
|
||||
|
||||
expect(files).toContain('/projects/material/src/app/foo/foo.component.css');
|
||||
@@ -28,8 +28,8 @@ describe('Material tree schematic', () => {
|
||||
expect(moduleContent).toMatch(/declarations:\s*\[[^\]]+?,\r?\n\s+FooComponent\r?\n/m);
|
||||
});
|
||||
|
||||
it('should add tree imports to module', () => {
|
||||
const tree = runner.runSchematic('tree', baseOptions, createTestApp(runner));
|
||||
it('should add tree imports to module', async () => {
|
||||
const tree = runner.runSchematic('tree', baseOptions, await createTestApp(runner));
|
||||
const moduleContent = getFileContent(tree, '/projects/material/src/app/app.module.ts');
|
||||
|
||||
expect(moduleContent).toContain('MatTreeModule');
|
||||
@@ -37,71 +37,72 @@ describe('Material tree schematic', () => {
|
||||
expect(moduleContent).toContain('MatButtonModule');
|
||||
});
|
||||
|
||||
it('should throw if no name has been specified', () => {
|
||||
it('should throw if no name has been specified', async () => {
|
||||
const appTree = await createTestApp(runner);
|
||||
expect(() => {
|
||||
runner.runSchematic('tree', {project: 'material'}, createTestApp(runner));
|
||||
runner.runSchematic('tree', {project: 'material'}, appTree);
|
||||
}).toThrowError(/required property 'name'/);
|
||||
});
|
||||
|
||||
describe('style option', () => {
|
||||
it('should respect the option value', () => {
|
||||
it('should respect the option value', async () => {
|
||||
const tree = runner.runSchematic(
|
||||
'tree', {style: 'scss', ...baseOptions}, createTestApp(runner));
|
||||
'tree', {style: 'scss', ...baseOptions}, await createTestApp(runner));
|
||||
|
||||
expect(tree.files).toContain('/projects/material/src/app/foo/foo.component.scss');
|
||||
});
|
||||
|
||||
it('should fall back to the @schematics/angular:component option value', () => {
|
||||
it('should fall back to the @schematics/angular:component option value', async () => {
|
||||
const tree = runner.runSchematic(
|
||||
'tree', baseOptions, createTestApp(runner, {style: 'less'}));
|
||||
'tree', baseOptions, await createTestApp(runner, {style: 'less'}));
|
||||
|
||||
expect(tree.files).toContain('/projects/material/src/app/foo/foo.component.less');
|
||||
});
|
||||
});
|
||||
|
||||
describe('inlineStyle option', () => {
|
||||
it('should respect the option value', () => {
|
||||
it('should respect the option value', async () => {
|
||||
const tree = runner.runSchematic(
|
||||
'tree', {inlineStyle: true, ...baseOptions}, createTestApp(runner));
|
||||
'tree', {inlineStyle: true, ...baseOptions}, await createTestApp(runner));
|
||||
|
||||
expect(tree.files).not.toContain('/projects/material/src/app/foo/foo.component.css');
|
||||
});
|
||||
|
||||
it('should fall back to the @schematics/angular:component option value', () => {
|
||||
it('should fall back to the @schematics/angular:component option value', async () => {
|
||||
const tree = runner.runSchematic(
|
||||
'tree', baseOptions, createTestApp(runner, {inlineStyle: true}));
|
||||
'tree', baseOptions, await createTestApp(runner, {inlineStyle: true}));
|
||||
|
||||
expect(tree.files).not.toContain('/projects/material/src/app/foo/foo.component.css');
|
||||
});
|
||||
});
|
||||
|
||||
describe('inlineTemplate option', () => {
|
||||
it('should respect the option value', () => {
|
||||
it('should respect the option value', async () => {
|
||||
const tree = runner.runSchematic(
|
||||
'tree', {inlineTemplate: true, ...baseOptions}, createTestApp(runner));
|
||||
'tree', {inlineTemplate: true, ...baseOptions}, await createTestApp(runner));
|
||||
|
||||
expect(tree.files).not.toContain('/projects/material/src/app/foo/foo.component.html');
|
||||
});
|
||||
|
||||
it('should fall back to the @schematics/angular:component option value', () => {
|
||||
it('should fall back to the @schematics/angular:component option value', async () => {
|
||||
const tree = runner.runSchematic(
|
||||
'tree', baseOptions, createTestApp(runner, {inlineTemplate: true}));
|
||||
'tree', baseOptions, await createTestApp(runner, {inlineTemplate: true}));
|
||||
|
||||
expect(tree.files).not.toContain('/projects/material/src/app/foo/foo.component.html');
|
||||
});
|
||||
});
|
||||
|
||||
describe('skipTests option', () => {
|
||||
it('should respect the option value', () => {
|
||||
it('should respect the option value', async () => {
|
||||
const tree = runner.runSchematic(
|
||||
'tree', {skipTests: true, ...baseOptions}, createTestApp(runner));
|
||||
'tree', {skipTests: true, ...baseOptions}, await createTestApp(runner));
|
||||
|
||||
expect(tree.files).not.toContain('/projects/material/src/app/foo/foo.component.spec.ts');
|
||||
});
|
||||
|
||||
it('should fall back to the @schematics/angular:component option value', () => {
|
||||
it('should fall back to the @schematics/angular:component option value', async () => {
|
||||
const tree = runner.runSchematic(
|
||||
'tree', baseOptions, createTestApp(runner, {skipTests: true}));
|
||||
'tree', baseOptions, await createTestApp(runner, {skipTests: true}));
|
||||
|
||||
expect(tree.files).not.toContain('/projects/material/src/app/foo/foo.component.spec.ts');
|
||||
});
|
||||
|
||||
@@ -4,7 +4,7 @@ import {createTestCaseSetup} from '@angular/cdk/schematics/testing';
|
||||
describe('constructor checks', () => {
|
||||
|
||||
it('should properly report invalid constructor expression signatures', async () => {
|
||||
const {removeTempDir, runFixers} = createTestCaseSetup('migration-v6',
|
||||
const {removeTempDir, runFixers} = await createTestCaseSetup('migration-v6',
|
||||
migrationCollection, [require.resolve('./constructor-checks_input.ts')]);
|
||||
|
||||
const {logOutput} = await runFixers();
|
||||
|
||||
@@ -4,7 +4,7 @@ import {migrationCollection} from '../index.spec';
|
||||
describe('v6 import misc checks', () => {
|
||||
|
||||
it('should report imports for deleted animation constants', async () => {
|
||||
const {removeTempDir, runFixers} = createTestCaseSetup('migration-v6',
|
||||
const {removeTempDir, runFixers} = await createTestCaseSetup('migration-v6',
|
||||
migrationCollection, [require.resolve('./import-checks_input.ts')]);
|
||||
|
||||
const {logOutput} = await runFixers();
|
||||
|
||||
@@ -12,7 +12,7 @@ describe('v8 material imports', () => {
|
||||
}
|
||||
|
||||
it('should report imports for deleted animation constants', async () => {
|
||||
const {runFixers, removeTempDir, tempPath} = createTestCaseSetup(
|
||||
const {runFixers, removeTempDir, tempPath} = await createTestCaseSetup(
|
||||
'migration-v8', migrationCollection, [require.resolve('./material-imports_input.ts')]);
|
||||
const materialPath = join(tempPath, 'node_modules/@angular/material');
|
||||
|
||||
|
||||
@@ -71,7 +71,12 @@ function addImportAs(packageName: string, outputPath: string, secondaryEntryPoin
|
||||
function addIdToGlob(outputPath: string, entryPointId: number): void {
|
||||
glob(join(outputPath, '**/*.+(js|d.ts|metadata.json)')).forEach(filePath => {
|
||||
let fileContent = readFileSync(filePath, 'utf-8');
|
||||
fileContent = fileContent.replace(/(ɵ[a-z]+)/g, `$1${entryPointId}`);
|
||||
// We check for double ɵ to avoid mangling symbols like `ɵɵdefineInjectable`.
|
||||
fileContent = fileContent.replace(/ɵ(ɵ)?[a-z]+/g,
|
||||
(match, isDoubleTheta) => {
|
||||
return isDoubleTheta ? match : match + entryPointId;
|
||||
});
|
||||
writeFileSync(filePath, fileContent, 'utf-8');
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
load("@angular//tools/ts-api-guardian:index.bzl", "ts_api_guardian_test")
|
||||
load("@npm_ts_api_guardian//:index.bzl", "ts_api_guardian_test")
|
||||
|
||||
"""
|
||||
Macro for generating ts-api-guardian Bazel test targets. Since there are multiple golden files
|
||||
|
||||
Reference in New Issue
Block a user