UNPKG

@nstudio/ionic-angular

Version:

Ionic Angular Plugin for xplat

75 lines (74 loc) 4.98 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 ionic angular', () => { let appTree; const defaultOptions = { npmScope: 'testing', prefix: 'ft', // foo test platforms: 'ionic', }; beforeEach(() => { appTree = schematics_1.Tree.empty(); appTree = (0, testing_1.createEmptyWorkspace)(appTree, 'angular'); }); xit('should create default xplat support for ionic which should always include web as well', () => __awaiter(void 0, void 0, void 0, function* () { const options = Object.assign({}, defaultOptions); const tree = yield (0, testing_2.runSchematic)('xplat', options, appTree); const files = tree.files; expect(files.indexOf('/libs/xplat/web/core/src/lib/index.ts')).toBeGreaterThanOrEqual(0); expect(files.indexOf('/libs/xplat/ionic/core/src/lib/index.ts')).toBeGreaterThanOrEqual(0); expect(files.indexOf('/xplat/nativescript/index.ts')).toBeGreaterThanOrEqual(-1); const packagePath = '/package.json'; const packageFile = (0, xplat_utils_1.jsonParse)((0, testing_1.getFileContent)(tree, packagePath)); // const hasScss = packageFile.dependencies[`@testing/scss`]; // expect(hasScss).not.toBeUndefined(); const hasWebScss = packageFile.dependencies[`@testing/xplat-web-scss`]; expect(hasWebScss).not.toBeUndefined(); // should not include these root packages const hasNativeScript = packageFile.dependencies[`nativescript-angular`]; expect(hasNativeScript).toBeUndefined(); 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/ionic/core']).toBeTruthy(); })); 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/ionic-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/ionic-angular/core']).toBeTruthy(); })); it('when default framework is set, can still create base platform support', () => __awaiter(void 0, void 0, void 0, function* () { appTree = schematics_1.Tree.empty(); appTree = (0, testing_1.createEmptyWorkspace)(appTree); let options = Object.assign({}, defaultOptions); options.framework = 'angular'; let tree = yield (0, testing_2.runSchematic)('xplat', options, appTree); expect(tree.exists('/libs/xplat/ionic/core/src/lib/index.ts')).toBeTruthy(); 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/ionic/core']).toBeTruthy(); expect(fileContent.compilerOptions.paths['@testing/xplat/ionic/features']).toBeTruthy(); yield expect((0, testing_2.runSchematic)('xplat', defaultOptions, tree)).rejects.toThrow(`You currently have "angular" set as your default frontend framework and have already generated xplat support for "ionic". A command is coming soon to auto reconfigure your workspace to later add baseline platform support for those which have previously been generated prepaired with a frontend framework.`); })); });