How to use the @angular-devkit/schematics/testing.UnitTestTree function in @angular-devkit/schematics

To help you get started, we’ve selected a few @angular-devkit/schematics examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github angular / angular-cli / packages / angular_devkit / schematics / src / rules / template_spec.ts View on Github external
it('works with template files exclusively', done => {
    const tree = new UnitTestTree(new HostTree());
    tree.create('a/b/file1', 'hello world');
    tree.create('a/b/file2', 'hello world');
    tree.create('a/b/file3.template', 'hello <%= 1 %> world');
    tree.create('a/b/file__a__.template', 'hello <%= 1 %> world');
    tree.create('a/b/file__norename__', 'hello <%= 1 %> world');
    tree.create('a/c/file4', 'hello world');

    const context: SchematicContext = {
      strategy: MergeStrategy.Default,
    } as SchematicContext;

    // Rename all files that contain 'b' to 'hello'.
    callRule(applyTemplates({ a: 'foo' }), observableOf(tree), context)
      .toPromise()
      .then(() => {
        expect([...tree.files].sort()).toEqual([
github co-IT / schematics / packages / schematics / src / cypress / index.spec.ts View on Github external
beforeEach(() => {
    treeBefore = new UnitTestTree(Tree.empty());
    runner = new SchematicTestRunner('schematics', collectionPath);
  });
github co-IT / schematics / packages / schematics / src / tsconfig / index.spec.ts View on Github external
beforeEach(() => {
      project = new UnitTestTree(Tree.empty());
      project.create('tsconfig.json', JSON.stringify({}));

      runner = new SchematicTestRunner('schematics', collectionPath);
    });
github kentan-official / kentan / packages / schematics / src / install / index.spec.ts View on Github external
beforeEach(() => {
    const config = { apps: [{ root: 'src' }] };

    collectionPath = join(__dirname, '../collection.json');
    runner = new SchematicTestRunner('kentan', collectionPath);

    childLogger = {
      info: jest.fn(),
      fatal: jest.fn()
    };

    logger = { createChild: () => childLogger };
    runner['_logger'] = logger;

    tree = new UnitTestTree(new VirtualTree());
    tree.create('.angular-cli.json', JSON.stringify(config));

    UseMock.globalCliConfiguration();
  });
github IgniteUI / igniteui-cli / migrations / update-3 / index.spec.ts View on Github external
beforeEach(() => {
		appTree = new UnitTestTree(new EmptyTree());
	});
github angular / angular-cli / packages / schematics / angular / migrations / update-8 / update-lazy-module-paths_spec.ts View on Github external
beforeEach(async () => {
      tree = new UnitTestTree(new EmptyTree());
      tree.create('/package.json', JSON.stringify({}));
    });
github angular / angular-cli / packages / schematics / angular / migrations / update-8 / codelyzer-5_spec.ts View on Github external
beforeEach(() => {
      tree = new UnitTestTree(new EmptyTree());
      tree.create(configPath, JSON.stringify(baseConfig, null, 2));
      tree.create(packageJsonPath, JSON.stringify(packageJson, null, 2));
      tree.create(tslintPath, JSON.stringify(tslintConfig, null, 2));
    });
github angular / angular-cli / packages / schematics / angular / migrations / update-8 / remove-angular-http_spec.ts View on Github external
beforeEach(() => {
      tree = new UnitTestTree(new EmptyTree());
      tree.create(packageJsonPath, JSON.stringify(packageJson, null, 2));
    });
github ngrx / platform / modules / store / migrations / 8_0_0-beta / index.spec.ts View on Github external
beforeEach(() => {
    appTree = new UnitTestTree(Tree.empty());
    appTree.create(
      '/tsconfig.json',
      `
        {
          "include": [**./*.ts"]
        }
       `
    );
    createPackageJson('', pkgName, appTree);
  });