本文整理汇总了TypeScript中@angular-devkit/schematics/testing.SchematicTestRunner.runSchematicAsync方法的典型用法代码示例。如果您正苦于以下问题:TypeScript SchematicTestRunner.runSchematicAsync方法的具体用法?TypeScript SchematicTestRunner.runSchematicAsync怎么用?TypeScript SchematicTestRunner.runSchematicAsync使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类@angular-devkit/schematics/testing.SchematicTestRunner
的用法示例。
在下文中一共展示了SchematicTestRunner.runSchematicAsync方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: it
it('should not fail when AppModule have imported RouterModule already', async () => {
const updateRecorder = appTree.beginUpdate('/projects/bar/src/app/app.module.ts');
updateRecorder.insertLeft(0, 'import { RouterModule } from \'@angular/router\';');
appTree.commitUpdate(updateRecorder);
const tree = await schematicRunner.runSchematicAsync('appShell', defaultOptions, appTree)
.toPromise();
const filePath = '/projects/bar/src/app/app.module.ts';
const content = tree.readContent(filePath);
expect(content).toMatch(/import { RouterModule } from \'@angular\/router\';/);
});
示例2: it
it('should create icon files', (done) => {
const dimensions = [72, 96, 128, 144, 152, 192, 384, 512];
const iconPath = '/projects/bar/src/assets/icons/icon-';
schematicRunner.runSchematicAsync('ng-add', defaultOptions, appTree).toPromise().then(tree => {
dimensions.forEach(d => {
const path = `${iconPath}${d}x${d}.png`;
expect(tree.exists(path)).toEqual(true);
});
done();
}, done.fail);
});
示例3: it
it('should work as expected for a project with a root', async () => {
const originalContent = JSON.parse(tree.readContent('angular.json'));
originalContent.projects['migration-test'].root = 'src';
tree.overwrite('angular.json', JSON.stringify(originalContent));
const polyfillPath = '/src/polyfills.ts';
tree.overwrite(polyfillPath, oldPolyfills);
const tree2 = await schematicRunner.runSchematicAsync('migration-03', {}, tree.branch())
.toPromise();
expect(tree2.readContent(polyfillPath)).not.toMatch(/import .*es7.*reflect.*;/);
});
示例4: it
it('should not add a theme file multiple times', async () => {
writeStyleFileToWorkspace(appTree, defaultPrebuiltThemePath);
const tree = await runner.runSchematicAsync('ng-add-setup-project', {}, appTree).toPromise();
const workspace = getWorkspace(tree);
const project = getProjectFromWorkspace(workspace);
const styles = getProjectTargetOptions(project, 'build').styles;
expect(styles).toEqual(['projects/material/src/styles.css', defaultPrebuiltThemePath],
'Expected the "styles.css" file and default prebuilt theme to be the only styles');
});