本文整理汇总了TypeScript中@angular-devkit/schematics/testing.UnitTestTree.rename方法的典型用法代码示例。如果您正苦于以下问题:TypeScript UnitTestTree.rename方法的具体用法?TypeScript UnitTestTree.rename怎么用?TypeScript UnitTestTree.rename使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类@angular-devkit/schematics/testing.UnitTestTree
的用法示例。
在下文中一共展示了UnitTestTree.rename方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: it
it('should respect the sourceRoot value', () => {
const config = JSON.parse(appTree.readContent('/angular.json'));
config.projects.bar.sourceRoot = 'projects/bar/custom';
appTree.overwrite('/angular.json', JSON.stringify(config, null, 2));
// should fail without a module in that dir
expect(() => schematicRunner.runSchematic('directive', defaultOptions, appTree)).toThrow();
// move the module
appTree.rename('/projects/bar/src/app/app.module.ts', '/projects/bar/custom/app/app.module.ts');
appTree = schematicRunner.runSchematic('directive', defaultOptions, appTree);
expect(appTree.files).toContain('/projects/bar/custom/app/foo.directive.ts');
});
示例2: it
it('should respect the sourceRoot value', async () => {
const config = JSON.parse(appTree.readContent('/angular.json'));
config.projects.bar.sourceRoot = 'projects/bar/custom';
appTree.overwrite('/angular.json', JSON.stringify(config, null, 2));
// should fail without a module in that dir
await expectAsync(
schematicRunner.runSchematicAsync('pipe', defaultOptions, appTree).toPromise(),
).toBeRejected();
// move the module
appTree.rename('/projects/bar/src/app/app.module.ts', '/projects/bar/custom/app/app.module.ts');
appTree = await schematicRunner.runSchematicAsync('pipe', defaultOptions, appTree).toPromise();
expect(appTree.files).toContain('/projects/bar/custom/app/foo.pipe.ts');
});