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