本文整理汇总了TypeScript中@angular-devkit/schematics/testing.UnitTestTree.delete方法的典型用法代码示例。如果您正苦于以下问题:TypeScript UnitTestTree.delete方法的具体用法?TypeScript UnitTestTree.delete怎么用?TypeScript UnitTestTree.delete使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类@angular-devkit/schematics/testing.UnitTestTree
的用法示例。
在下文中一共展示了UnitTestTree.delete方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: makeInlineTemplate
function makeInlineTemplate(tree: UnitTestTree, template?: string): void {
template = template || `
<p>
App works!
</p>`;
const newText = `
import { Component, OnInit } from '@angular/core';
@Component({
selector: ''
template: \`
${template}
\`,
styleUrls: ['./app.component.css']
})
export class AppComponent implements OnInit {
constructor() { }
ngOnInit() {
}
}
`;
tree.overwrite('/projects/bar/src/app/app.component.ts', newText);
tree.delete('/projects/bar/src/app/app.component.html');
}
示例2: it
it(`should create browserslist file if it doesn't exist`, () => {
tree.delete('/browserslist');
const tree2 = schematicRunner.runSchematic('migration-07', {}, tree.branch());
expect(tree2.exists('/browserslist')).toBe(true);
expect(tree2.readContent('/browserslist'))
.toContain('Support for Googlebot');
});
示例3: it
it('should add production configuration when no production environment', () => {
tree.delete('/src/environments/environment.prod.ts');
tree.create(oldConfigPath, JSON.stringify(baseConfig, null, 2));
tree = schematicRunner.runSchematic('migration-01', defaultOptions, tree);
const config = getConfig(tree);
expect(config.projects.foo.targets.build.configurations).toEqual({
prod: {
fileReplacements: [{
replace: 'src/environments/environment.ts',
with: 'src/environments/environment.prod.ts',
}],
},
production: {
optimization: true,
outputHashing: 'all',
sourceMap: false,
extractCss: true,
namedChunks: false,
aot: true,
extractLicenses: true,
vendorChunk: false,
buildOptimizer: true,
},
});
});
示例4: it
it('should properly add css reset', () => {
tree.create('src/styles.scss', '');
runner.runSchematic('ng-add', { normalizeCss: true }, tree);
let pkgJsonData = JSON.parse(tree.readContent('/package.json'));
expect(tree.readContent('src/styles.scss')).toEqual(scssImport);
expect(pkgJsonData.dependencies['minireset.css']).toBeTruthy();
resetJsonConfigs(tree);
tree.delete('src/styles.scss');
tree.create('src/styles.sass', '');
runner.runSchematic('ng-add', { normalizeCss: true }, tree);
pkgJsonData = JSON.parse(tree.readContent('/package.json'));
expect(tree.readContent('src/styles.sass')).toEqual(scssImport);
expect(pkgJsonData.dependencies['minireset.css']).toBeTruthy();
resetJsonConfigs(tree);
tree.delete('src/styles.sass');
tree.create('src/styles.css', '');
runner.runSchematic('ng-add', { normalizeCss: true }, tree);
pkgJsonData = JSON.parse(tree.readContent('/package.json'));
expect(tree.readContent('src/styles.css')).toBe('');
expect(pkgJsonData.dependencies['minireset.css']).toBeTruthy();
expect(JSON.parse(tree.readContent('/angular.json')).projects['testProj'].architect.build.options.styles).toContain(cssImport);
resetJsonConfigs(tree);
tree.delete('src/styles.css');
tree.create('src/styles.less', '');
runner.runSchematic('ng-add', { normalizeCss: true }, tree);
pkgJsonData = JSON.parse(tree.readContent('/package.json'));
expect(tree.readContent('src/styles.less')).toBe('');
expect(pkgJsonData.dependencies['minireset.css']).toBeTruthy();
expect(JSON.parse(tree.readContent('/angular.json')).projects['testProj'].architect.build.options.styles).toContain(cssImport);
resetJsonConfigs(tree);
tree.delete('src/styles.less');
tree.create('src/styles.styl', '');
runner.runSchematic('ng-add', { normalizeCss: true }, tree);
pkgJsonData = JSON.parse(tree.readContent('/package.json'));
expect(tree.readContent('src/styles.styl')).toBe('');
expect(pkgJsonData.dependencies['minireset.css']).toBeTruthy();
expect(JSON.parse(tree.readContent('/angular.json')).projects['testProj'].architect.build.options.styles).toContain(cssImport);
resetJsonConfigs(tree);
tree.delete('src/styles.styl');
});
示例5: runTest
function runTest(testFn: Function, obj: JsonValue, indent: number): string {
const content = JSON.stringify(obj, null, indent);
tree.create(filePath, content);
const ast = parseJsonAst(content);
const rec = tree.beginUpdate(filePath);
testFn(rec, ast);
tree.commitUpdate(rec);
const result = tree.readContent(filePath);
// Clean up the tree by deleting the file.
tree.delete(filePath);
return result;
}
示例6: runTest
function runTest(obj: Pojso, prop: string, val: string): Pojso {
const content = JSON.stringify(obj, null, 2);
tree.create(filePath, content);
const ast = parseJsonAst(content);
const rec = tree.beginUpdate(filePath);
if (ast.kind === 'object') {
insertPropertyInAstObjectInOrder(rec, ast, prop, val, 2);
}
tree.commitUpdate(rec);
const result = JSON.parse(tree.readContent(filePath));
// Clean up the tree by deleting the file.
tree.delete(filePath);
return result;
}
示例7: it
it('throws if angular.json is not found', () => {
expect(host.files).toContain('/angular.json');
host.delete('/angular.json');
expect(() => schematicRunner.runSchematic('ng-add', defaultOptions, host))
.toThrowError('Could not find angular.json');
});