本文整理匯總了TypeScript中@angular-devkit/schematics/testing.SchematicTestRunner.runSchematic方法的典型用法代碼示例。如果您正苦於以下問題:TypeScript SchematicTestRunner.runSchematic方法的具體用法?TypeScript SchematicTestRunner.runSchematic怎麽用?TypeScript SchematicTestRunner.runSchematic使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類@angular-devkit/schematics/testing.SchematicTestRunner
的用法示例。
在下文中一共展示了SchematicTestRunner.runSchematic方法的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: it
it('should respect the option value', () => {
const tree = runner.runSchematic(
'drag-drop', {spec: false, ...baseOptions}, createTestApp(runner));
expect(tree.files).not.toContain('/projects/material/src/app/foo/foo.component.spec.ts');
});
示例2: beforeEach
beforeEach(() => {
appTree = schematicRunner.runSchematic('workspace', workspaceOptions);
appTree = schematicRunner.runSchematic('application', appOptions, appTree);
});
示例3: it
it('should create an class named "Foo"', () => {
const tree = schematicRunner.runSchematic('class', defaultOptions, appTree);
const fileContent = tree.readContent('/projects/bar/src/app/foo.ts');
expect(fileContent).toMatch(/export class Foo/);
});
示例4: expect
expect(() => {
runner.runSchematic('table', {project: 'material'}, createTestApp(runner));
}).toThrowError(/required property 'name'/);
示例5: it
it('should fall back to the @schematics/angular:component option value', () => {
const tree = runner.runSchematic(
'table', baseOptions, createTestApp(runner, {inlineStyle: true}));
expect(tree.files).not.toContain('/projects/material/src/app/foo/foo.component.css');
});
示例6: it
it('should have the latest Angular major versions in package.json named "foo"', () => {
const tree = schematicRunner.runSchematic('library', defaultOptions, workspaceTree);
const fileContent = getJsonFileContent(tree, '/projects/foo/package.json');
const angularVersion = latestVersions.Angular.replace('~', '').replace('^', '');
expect(fileContent.peerDependencies['@angular/core']).toBe(`^${angularVersion}`);
});
示例7: it
it('should create a guard', () => {
const tree = schematicRunner.runSchematic('guard', defaultOptions, appTree);
const files = tree.files;
expect(files.indexOf('/projects/bar/src/app/foo.guard.spec.ts')).toBeGreaterThanOrEqual(0);
expect(files.indexOf('/projects/bar/src/app/foo.guard.ts')).toBeGreaterThanOrEqual(0);
});
示例8: it
it('should add dependency: @angular/platform-server', () => {
const tree = schematicRunner.runSchematic('universal', defaultOptions, appTree);
const filePath = '/package.json';
const contents = tree.readContent(filePath);
expect(contents).toMatch(/\"@angular\/platform-server\": \"/);
});
示例9: it
it('should set the CLI version in package.json', () => {
const tree = schematicRunner.runSchematic('workspace', defaultOptions);
const pkg = JSON.parse(tree.readContent('/package.json'));
expect(pkg.devDependencies['@angular/cli']).toMatch('6.0.0');
});