/** * @license * Copyright Google Inc. All Rights Reserved. * * 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 { SchematicTestRunner, UnitTestTree } from '@angular-devkit/schematics/testing'; import { Schema as WorkspaceOptions } from "@schematics/angular/workspace/schema"; import { Schema as ApplicationOptions } from "@schematics/angular/application/schema"; // tslint:disable:max-line-length describe('Service Schematic', () => { const schematicRunner = new SchematicTestRunner( 'schematics', require.resolve('../collection.json'), ); const defaultOptions: any = { name: 'product', flat: false, project: 'example', }; const workspaceOptions: WorkspaceOptions = { name: 'example', version: '6.0.0', }; const appOptions: ApplicationOptions = { name: 'example', inlineStyle: false, inlineTemplate: false, routing: false, skipPackageJson: false, }; let appTree: UnitTestTree; beforeEach(() => { appTree = schematicRunner.runExternalSchematic("@schematics/angular", 'workspace', workspaceOptions); appTree = schematicRunner.runExternalSchematic("@schematics/angular", 'application', appOptions, appTree); }); it('should create a service', () => { const options = { ...defaultOptions }; const tree = schematicRunner.runSchematic('service', options, appTree); const files = tree.files; expect(files).toContain('/example/src/app/product/product.service.ts'); }); });