UNPKG

ngx-face-api-js

Version:

Angular directives for face detection and face recognition in the browser. It is a wrapper for face-api.js, so it is not dependent on the browser implementation.

83 lines 4.78 kB
"use strict"; var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { 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) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); } step((generator = generator.apply(thisArg, _arguments || [])).next()); }); }; Object.defineProperty(exports, "__esModule", { value: true }); const testing_1 = require("@angular-devkit/schematics/testing"); const test_1 = require("@schematics/angular/utility/test"); const path = require("path"); const config_1 = require("@schematics/angular/utility/config"); const schematics_1 = require("@angular/cdk/schematics"); const ng_ast_utils_1 = require("@schematics/angular/utility/ng-ast-utils"); const collectionPath = path.join(__dirname, '../collection.json'); function createTestApp(appOptions = {}) { const baseRunner = new testing_1.SchematicTestRunner('schematics', collectionPath); const workspaceTree = baseRunner.runExternalSchematic('@schematics/angular', 'workspace', { name: 'workspace', version: '7.1.2', newProjectRoot: 'projects', }); return baseRunner.runExternalSchematic('@schematics/angular', 'application', Object.assign({}, appOptions, { name: 'example-app' }), workspaceTree); } describe('ngx-face-api-js-schematics ng-add', () => { it('addDependencies works face-api.js', () => __awaiter(this, void 0, void 0, function* () { const runner = new testing_1.SchematicTestRunner('schematics', collectionPath); const tree = yield runner .runSchematicAsync('ng-add', {}, createTestApp()) .toPromise(); expect(tree.files).toContain('/package.json'); const packageJson = JSON.parse(test_1.getFileContent(tree, '/package.json')); expect(packageJson.dependencies['face-api.js']).toBe('~0.20.0'); })); it('addDependencies works @angular/cdk', () => __awaiter(this, void 0, void 0, function* () { const runner = new testing_1.SchematicTestRunner('schematics', collectionPath); const tree = yield runner .runSchematicAsync('ng-add', {}, createTestApp()) .toPromise(); expect(tree.files).toContain('/package.json'); const packageJson = JSON.parse(test_1.getFileContent(tree, '/package.json')); expect(Object.keys(packageJson.devDependencies)).toContain('@angular/cdk'); })); it('addBrowserIgnorePackageSetting works', () => __awaiter(this, void 0, void 0, function* () { const runner = new testing_1.SchematicTestRunner('schematics', collectionPath); const tree = yield runner .runSchematicAsync('ng-add', {}, createTestApp()) .toPromise(); expect(tree.files).toContain('/package.json'); const packageJson = JSON.parse(test_1.getFileContent(tree, '/package.json')); expect(packageJson.browser.fs).toBe(false); expect(packageJson.browser.crypto).toBe(false); })); it('addCdkOverlayPrebuiltCssToAppStyles works', () => __awaiter(this, void 0, void 0, function* () { const runner = new testing_1.SchematicTestRunner('schematics', collectionPath); const tree = yield runner .runSchematicAsync('ng-add', {}, createTestApp()) .toPromise(); const workspace = config_1.getWorkspace(tree); const project = schematics_1.getProjectFromWorkspace(workspace); const styleFilePath = schematics_1.getProjectStyleFile(project); if (styleFilePath) { const stylesScss = test_1.getFileContent(tree, styleFilePath); expect(stylesScss).toMatch(`@import '~@angular/cdk/overlay-prebuilt.css'`); } })); it('addNgxFaceApiJsModule works', () => __awaiter(this, void 0, void 0, function* () { const runner = new testing_1.SchematicTestRunner('schematics', collectionPath); const tree = yield runner .runSchematicAsync('ng-add', {}, createTestApp()) .toPromise(); const workspace = config_1.getWorkspace(tree); const project = schematics_1.getProjectFromWorkspace(workspace); const appModulePath = ng_ast_utils_1.getAppModulePath(tree, schematics_1.getProjectMainFile(project)); if (appModulePath) { const appModuleContent = test_1.getFileContent(tree, appModulePath); expect(appModuleContent).toMatch('NgxFaceApiJsModule.forRoot'); } })); }); //# sourceMappingURL=index.spec.js.map