本文整理汇总了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');
});