UNPKG

@nstudio/web-angular

Version:

Web Angular Plugin for xplat

59 lines (58 loc) 3.52 kB
"use strict"; var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } return new (P || (P = Promise))(function (resolve, reject) { function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } step((generator = generator.apply(thisArg, _arguments || [])).next()); }); }; Object.defineProperty(exports, "__esModule", { value: true }); const schematics_1 = require("@angular-devkit/schematics"); const xplat_utils_1 = require("@nstudio/xplat-utils"); const testing_1 = require("@nstudio/xplat/testing"); const testing_2 = require("../../utils/testing"); (0, xplat_utils_1.setTest)(); describe('xplat schematic', () => { let appTree; const defaultOptions = { npmScope: 'testing', prefix: 'ft', // foo test platforms: 'web', }; beforeEach(() => { appTree = schematics_1.Tree.empty(); appTree = (0, testing_1.createEmptyWorkspace)(appTree, 'angular'); }); it('should create default xplat support for web only', () => __awaiter(void 0, void 0, void 0, function* () { const options = Object.assign({}, defaultOptions); const tree = yield (0, testing_2.runSchematic)('xplat', options, appTree); expect(tree.exists('/libs/xplat/web/core/src/lib/index.ts')).toBeTruthy(); expect(tree.exists('/libs/xplat/nativescript/core/src/lib/index.ts')).toBeFalsy(); let filePath = (0, xplat_utils_1.getRootTsConfigPath)(); let fileContent = (0, xplat_utils_1.jsonParse)((0, testing_1.getFileContent)(tree, filePath)); // console.log(fileContent); expect(fileContent.compilerOptions.paths['@testing/xplat/web/core']).toBeTruthy(); expect(fileContent.compilerOptions.paths['@testing/xplat/web/features']).toBeTruthy(); filePath = '/package.json'; fileContent = (0, xplat_utils_1.jsonParse)((0, testing_1.getFileContent)(tree, filePath)); // const hasScss = packageFile.dependencies[`@testing/scss`]; // expect(hasScss).not.toBeUndefined(); // should not include these root packages const hasNativeScript = fileContent.dependencies[`nativescript-angular`]; expect(hasNativeScript).toBeUndefined(); })); it('should create default xplat support with framework suffix when not specifying default', () => __awaiter(void 0, void 0, void 0, function* () { appTree = schematics_1.Tree.empty(); appTree = (0, testing_1.createEmptyWorkspace)(appTree); const options = Object.assign({}, defaultOptions); const tree = yield (0, testing_2.runSchematic)('xplat', options, appTree); expect(tree.exists('/libs/xplat/web-angular/core/src/lib/index.ts')).toBeTruthy(); const filePath = (0, xplat_utils_1.getRootTsConfigPath)(); const fileContent = (0, xplat_utils_1.jsonParse)((0, testing_1.getFileContent)(tree, filePath)); // console.log(fileContent); expect(fileContent.compilerOptions.paths['@testing/xplat/web-angular/core']).toBeTruthy(); expect(fileContent.compilerOptions.paths['@testing/xplat/web-angular/features']).toBeTruthy(); })); });