How to use the @nstudio/xplat/testing.getFileContent function in @nstudio/xplat

To help you get started, we’ve selected a few @nstudio/xplat 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 nstudio / xplat / packages / nativescript / src / schematics / xplat / index.spec.ts View on Github external
it('should create default xplat support for nativescript only', async () => {
    const options: XplatHelpers.Schema = { ...defaultOptions };

    appTree.create('.prettierignore', '# sample');
    const tree = await runSchematic('xplat', options, appTree);
    expect(tree.exists('/xplat/web/index.ts')).toBeFalsy();
    expect(tree.exists('/xplat/nativescript/index.ts')).toBeTruthy();
    const packagePath = '/package.json';
    const packageFile = jsonParse(getFileContent(tree, packagePath));
    const hasNativeScript = packageFile.dependencies[`tns-core-modules`];
    expect(hasNativeScript).not.toBeUndefined();

    const prettier = getFileContent(tree, '.prettierignore');
    // console.log('prettier:', prettier);
    expect(
      prettier.indexOf('**/xplat/nativescript*/plugins/**/*')
    ).toBeGreaterThan(0);
  });
});
github nstudio / xplat / packages / xplat / src / schematics / component / index.spec.ts View on Github external
let barrelIndex = getFileContent(tree, barrelPath);
    // console.log(barrelPath + ':');
    // console.log(barrelIndex);
    expect(barrelIndex.indexOf(`./signup.base-component`)).toBeTruthy();

    barrelPath = '/libs/features/foo/base/index.ts';
    barrelIndex = getFileContent(tree, barrelPath);
    // console.log(barrelPath + ':');
    // console.log(barrelIndex);
    // component symbol should be at end of components collection
    expect(barrelIndex.indexOf(`./registration`)).toBeGreaterThanOrEqual(0);

    // file content
    barrelPath =
      '/xplat/nativescript/features/foo/components/registration/index.ts';
    barrelIndex = getFileContent(tree, barrelPath);
    // console.log(barrelPath + ':');
    // console.log(barrelIndex);
    // component symbol should be at end of components collection
    expect(barrelIndex.indexOf(`SignupComponent];`)).toBeGreaterThanOrEqual(0);
    expect(
      barrelIndex.indexOf(`./signup/signup.component`)
    ).toBeGreaterThanOrEqual(0);

    barrelPath = '/xplat/web/features/foo/components/registration/index.ts';
    barrelIndex = getFileContent(tree, barrelPath);
    // console.log(barrelPath + ':');
    // console.log(barrelIndex);
    expect(barrelIndex.indexOf(`SignupComponent];`)).toBeGreaterThanOrEqual(0);

    // file content
    barrelPath = '/xplat/nativescript/features/foo/components/index.ts';
github nstudio / xplat / packages / angular / src / schematics / service / index.spec.ts View on Github external
).toBeGreaterThanOrEqual(0);
    // should NOT add for other platform
    expect(
      files.indexOf('/xplat/web/features/foo/services/auth.service.ts')
    ).toBe(-1);

    // file content
    let content = getFileContent(
      tree,
      '/xplat/nativescript/features/foo/services/auth.service.ts'
    );
    // console.log(content);
    expect(content.indexOf(`@Injectable()`)).toBeGreaterThanOrEqual(0);
    expect(content.indexOf(`AuthService`)).toBeGreaterThanOrEqual(0);

    content = getFileContent(
      tree,
      '/xplat/nativescript/features/foo/services/index.ts'
    );
    // console.log(content);
    expect(content.indexOf(`AuthService`)).toBeGreaterThanOrEqual(0);

    let modulePath = '/xplat/nativescript/features/foo/foo.module.ts';
    let moduleContent = getFileContent(tree, modulePath);
    // console.log(modulePath + ':');
    // console.log(moduleContent);
    expect(moduleContent.indexOf(`...FOO_PROVIDERS`)).toBeGreaterThanOrEqual(0);
  });
github nstudio / xplat / packages / electron / src / schematics / application / index.spec.ts View on Github external
let checkFile = getFileContent(tree, checkPath);
    expect(
      checkFile.indexOf(`path.join(__dirname, 'index.html')`)
    ).toBeGreaterThanOrEqual(0);
    expect(
      files.indexOf('/apps/electron-foo/src/icons/icon.png')
    ).toBeGreaterThanOrEqual(0);
    expect(
      files.indexOf('/apps/electron-foo/tsconfig.json')
    ).toBeGreaterThanOrEqual(0);

    checkPath = '/apps/electron-foo/src/package.json';
    expect(files.indexOf(checkPath)).toBeGreaterThanOrEqual(0);

    checkFile = getFileContent(tree, checkPath);
    // console.log(checkFile);
    expect(checkFile.indexOf(`"name": "foo"`)).toBeGreaterThanOrEqual(0);

    // expect(
    //   files.indexOf('/tools/electron/postinstall.js')
    // ).toBeGreaterThanOrEqual(0);
    // expect(files.indexOf('/tools/web/postinstall.js')).toBeGreaterThanOrEqual(
    //   0
    // );

    checkPath = '/package.json';
    expect(files.indexOf(checkPath)).toBeGreaterThanOrEqual(0);

    checkFile = getFileContent(tree, checkPath);
    // console.log(checkFile);
    const packageData: any = jsonParse(checkFile);
github nstudio / xplat / packages / angular / src / schematics / elements / index.spec.ts View on Github external
let elementModule = getFileContent(tree, elementModulePath);
    // console.log(elementModule);
    expect(
      elementModule.indexOf(
        `import { MenuComponent, FooterComponent } from '@mycompany/web';`
      )
    ).toBeGreaterThanOrEqual(0);

    let builderPath = '/xplat/web/elements/builder/elements.ts';
    expect(files.indexOf(builderPath)).toBeGreaterThanOrEqual(0);
    let builderModule = getFileContent(tree, builderPath);
    // console.log(builderModule);
    expect(builderModule.indexOf(`../ui-kit.module`)).toBeGreaterThanOrEqual(0);
    let builderIndexPath = '/xplat/web/elements/builder/index.html';
    expect(files.indexOf(builderPath)).toBeGreaterThanOrEqual(0);
    let builderIndex = getFileContent(tree, builderIndexPath);
    // console.log(builderIndex);
    expect(builderIndex.indexOf(``)).toBeGreaterThanOrEqual(
      0
    );
    expect(
      builderIndex.indexOf(``)
    ).toBeGreaterThanOrEqual(0);

    const component2Options: XplatComponentHelpers.Schema = {
      name: 'dropdown',
      platforms: 'web'
    };
    tree = await runSchematic('component', component2Options, tree);
    component2Options.name = 'link';
    tree = await runSchematic('component', component2Options, tree);
    files = tree.files;
github nstudio / xplat / packages / angular / src / schematics / service / index.spec.ts View on Github external
files.indexOf(
        '/apps/web-viewer/src/app/features/foo/services/auth.service.ts'
      )
    ).toBeGreaterThanOrEqual(0);

    // file content
    let indexPath =
      '/apps/nativescript-viewer/src/features/foo/services/index.ts';
    let index = getFileContent(tree, indexPath);
    // console.log(barrelPath + ':');
    // console.log(barrelIndex);
    // symbol should be at end of components collection
    expect(index.indexOf(`AuthService`)).toBeGreaterThanOrEqual(0);

    let modulePath = '/apps/nativescript-viewer/src/features/foo/foo.module.ts';
    let moduleContent = getFileContent(tree, modulePath);
    // console.log(modulePath + ':');
    // console.log(moduleContent);
    expect(moduleContent.indexOf(`...FOO_PROVIDERS`)).toBeGreaterThanOrEqual(0);

    indexPath = '/apps/web-viewer/src/app/features/foo/services/index.ts';
    index = getFileContent(tree, indexPath);
    // console.log(barrelPath + ':');
    // console.log(barrelIndex);
    expect(index.indexOf(`AuthService`)).toBeGreaterThanOrEqual(0);
  });
github nstudio / xplat / packages / angular / src / schematics / helpers / index.spec.ts View on Github external
target: 'web-foo'
    };
    // console.log('appTree:', appTree);
    const tree = await runSchematic('helpers', options, appTree);
    const files = tree.files;
    // console.log(files);

    expect(
      files.indexOf('/apps/web-foo-e2e/src/support/index.ts')
    ).toBeGreaterThanOrEqual(0);
    expect(
      files.indexOf('/apps/web-foo-e2e/src/plugins/index.ts')
    ).toBeGreaterThanOrEqual(0);
    // modified testing files
    let filePath = '/apps/web-foo-e2e/src/support/index.ts';
    fileContent = getFileContent(tree, filePath);
    // console.log(fileContent);

    expect(
      fileContent.indexOf('@applitools/eyes-cypress/commands')
    ).toBeGreaterThanOrEqual(0);

    filePath = '/apps/web-foo-e2e/src/plugins/index.ts';
    fileContent = getFileContent(tree, filePath);
    // console.log(fileContent);

    expect(
      fileContent.indexOf(`require('@applitools/eyes-cypress')(module);`)
    ).toBeGreaterThanOrEqual(0);

    fileContent = getFileContent(tree, cypressJsonPath);
    // console.log(fileContent);
github nstudio / xplat / packages / angular / src / schematics / feature / index.spec.ts View on Github external
files.indexOf('/apps/web-viewer/src/app/features/foo/foo.module.ts')
    ).toBeGreaterThanOrEqual(-1);
    expect(
      files.indexOf(
        '/apps/web-viewer/src/app/features/foo/components/foo/foo.component.html'
      )
    ).toBeGreaterThanOrEqual(-1);
    expect(
      files.indexOf(
        '/apps/web-viewer/src/app/features/foo/components/foo/foo.component.ts'
      )
    ).toBeGreaterThanOrEqual(-1);

    // file content
    let modulePath = '/xplat/nativescript-angular/features/foo/foo.module.ts';
    let featureModule = getFileContent(tree, modulePath);
    // console.log(modulePath + ':');
    // console.log(featureModule);
    expect(featureModule).toMatch(
      isInModuleMetadata('FooModule', 'imports', `UIModule`, true)
    );
    expect(featureModule).toMatch(
      `import { UIModule } from \'../ui/ui.module\'`
    );

    modulePath = '/xplat/web-angular/features/foo/foo.module.ts';
    featureModule = getFileContent(tree, modulePath);
    // console.log(modulePath + ':');
    // console.log(featureModule);
    expect(featureModule).toMatch(
      isInModuleMetadata('FooModule', 'imports', `UIModule`, true)
    );
github nstudio / xplat / packages / angular / src / schematics / elements / index.spec.ts View on Github external
tree = await runSchematic('elements', options, tree);
    files = tree.files;

    let elementModulePath = '/xplat/web/elements/ui-kit.module.ts';
    expect(files.indexOf(elementModulePath)).toBeGreaterThanOrEqual(0);
    let elementModule = getFileContent(tree, elementModulePath);
    // console.log(elementModule);
    expect(
      elementModule.indexOf(
        `import { MenuComponent, FooterComponent } from '@mycompany/web';`
      )
    ).toBeGreaterThanOrEqual(0);

    let builderPath = '/xplat/web/elements/builder/elements.ts';
    expect(files.indexOf(builderPath)).toBeGreaterThanOrEqual(0);
    let builderModule = getFileContent(tree, builderPath);
    // console.log(builderModule);
    expect(builderModule.indexOf(`../ui-kit.module`)).toBeGreaterThanOrEqual(0);
    let builderIndexPath = '/xplat/web/elements/builder/index.html';
    expect(files.indexOf(builderPath)).toBeGreaterThanOrEqual(0);
    let builderIndex = getFileContent(tree, builderIndexPath);
    // console.log(builderIndex);
    expect(builderIndex.indexOf(``)).toBeGreaterThanOrEqual(
      0
    );
    expect(
      builderIndex.indexOf(``)
    ).toBeGreaterThanOrEqual(0);

    const component2Options: XplatComponentHelpers.Schema = {
      name: 'dropdown',
      platforms: 'web'
github nstudio / xplat / packages / electron-angular / src / schematics / application / index.spec.ts View on Github external
// console.log(checkFile);
    expect(checkFile.indexOf(`TtElectronCoreModule`)).toBeGreaterThanOrEqual(0);
    expect(checkFile.indexOf(`AppElectronModule`)).toBeGreaterThanOrEqual(0);

    checkPath = '/apps/web-viewer/src/main.electron.ts';
    expect(files.indexOf(checkPath)).toBeGreaterThanOrEqual(0);

    checkFile = getFileContent(tree, checkPath);
    // console.log(checkFile);
    expect(
      checkFile.indexOf(`./app/app.electron.module`)
    ).toBeGreaterThanOrEqual(0);

    // make sure start script is correct
    checkPath = '/package.json';
    checkFile = getFileContent(tree, checkPath);
    // console.log(checkFile);
    expect(
      checkFile.indexOf(
        `npm run prepare.electron.${options.name} && npm-run-all -p serve.electron.${options.name}.target serve.electron.${options.name}`
      )
    ).toBeGreaterThanOrEqual(0);
  });