@ -5,9 +5,9 @@
|
||||
* Use of this source code is governed by an MIT-style license that can be
|
||||
* found in the LICENSE file at https://angular.io/license
|
||||
*/
|
||||
import {Rule, SchematicContext, SchematicsException, Tree, chain, noop} from '@angular-devkit/schematics';
|
||||
import {chain, noop, Rule, SchematicContext, SchematicsException, Tree} from '@angular-devkit/schematics';
|
||||
import {NodePackageInstallTask} from '@angular-devkit/schematics/tasks';
|
||||
import {NodeDependencyType, addPackageJsonDependency} from '@schematics/angular/utility/dependencies';
|
||||
import {addPackageJsonDependency, NodeDependencyType} from '@schematics/angular/utility/dependencies';
|
||||
import {getWorkspace} from '@schematics/angular/utility/workspace';
|
||||
|
||||
import {Schema} from './schema';
|
||||
@ -36,7 +36,7 @@ function addPolyfillDependency(): Rule {
|
||||
|
||||
/** Adds the document-register-element.js to the polyfills file. */
|
||||
function addPolyfill(options: Schema): Rule {
|
||||
return async(host: Tree, context: SchematicContext) => {
|
||||
return async (host: Tree, context: SchematicContext) => {
|
||||
const projectName = options.project;
|
||||
|
||||
if (!projectName) {
|
||||
|
@ -13,7 +13,9 @@ import {Schema as ElementsOptions} from './schema';
|
||||
// tslint:disable:max-line-length
|
||||
describe('Elements Schematics', () => {
|
||||
const schematicRunner = new SchematicTestRunner(
|
||||
'@angular/elements', path.join(__dirname, '../test-collection.json'), );
|
||||
'@angular/elements',
|
||||
path.join(__dirname, '../test-collection.json'),
|
||||
);
|
||||
const defaultOptions: ElementsOptions = {project: 'elements', skipPackageJson: false};
|
||||
|
||||
let appTree: UnitTestTree;
|
||||
@ -35,7 +37,7 @@ describe('Elements Schematics', () => {
|
||||
skipTests: false,
|
||||
};
|
||||
|
||||
beforeEach(async() => {
|
||||
beforeEach(async () => {
|
||||
appTree = await schematicRunner
|
||||
.runExternalSchematicAsync('@schematics/angular', 'workspace', workspaceOptions)
|
||||
.toPromise();
|
||||
@ -45,14 +47,14 @@ describe('Elements Schematics', () => {
|
||||
.toPromise();
|
||||
});
|
||||
|
||||
it('should run the ng-add schematic', async() => {
|
||||
it('should run the ng-add schematic', async () => {
|
||||
const tree =
|
||||
await schematicRunner.runSchematicAsync('ng-add', defaultOptions, appTree).toPromise();
|
||||
expect(tree.readContent('/projects/elements/src/polyfills.ts'))
|
||||
.toContain(`import 'document-register-element';`);
|
||||
});
|
||||
|
||||
it('should add polyfill as a dependency in package.json', async() => {
|
||||
it('should add polyfill as a dependency in package.json', async () => {
|
||||
const tree =
|
||||
await schematicRunner.runSchematicAsync('ng-add', defaultOptions, appTree).toPromise();
|
||||
const pkgJsonText = tree.readContent('/package.json');
|
||||
|
Reference in New Issue
Block a user