@yolkai/nx-workspace
Version:
69 lines (68 loc) • 4.73 kB
JavaScript
;
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 schematics_1 = require("@angular-devkit/schematics");
const testing_1 = require("../../utils/testing");
const testing_2 = require("@yolkai/nx-workspace/testing");
describe('preset', () => {
let projectTree;
beforeEach(() => {
projectTree = testing_2.createEmptyWorkspace(schematics_1.Tree.empty());
});
it('should create files (preset = angular)', () => __awaiter(this, void 0, void 0, function* () {
const tree = yield testing_1.runSchematic('preset', { name: 'proj', preset: 'angular' }, projectTree);
expect(tree.exists('/apps/proj/src/app/app.component.ts')).toBe(true);
expect(JSON.parse(tree.readContent('/workspace.json')).cli.defaultCollection).toBe('@yolkai/nx-angular');
}));
it('should create files (preset = react)', () => __awaiter(this, void 0, void 0, function* () {
const tree = yield testing_1.runSchematic('preset', { name: 'proj', preset: 'react' }, projectTree);
expect(tree.exists('/apps/proj/src/main.tsx')).toBe(true);
expect(JSON.parse(tree.readContent('/workspace.json')).cli.defaultCollection).toBe('@yolkai/nx-react');
}));
it('should create files (preset = web-components)', () => __awaiter(this, void 0, void 0, function* () {
const tree = yield testing_1.runSchematic('preset', { name: 'proj', preset: 'web-components' }, projectTree);
expect(tree.exists('/apps/proj/src/main.ts')).toBe(true);
expect(JSON.parse(tree.readContent('/workspace.json')).cli.defaultCollection).toBe('@yolkai/nx-web');
}));
it('should create files (preset = next)', () => __awaiter(this, void 0, void 0, function* () {
const tree = yield testing_1.runSchematic('preset', { name: 'proj', preset: 'next' }, projectTree);
expect(tree.exists('/apps/proj/pages/index.tsx')).toBe(true);
expect(JSON.parse(tree.readContent('/workspace.json')).cli.defaultCollection).toBe('@yolkai/nx-next');
}));
describe('--preset angular-nest', () => {
it('should create files', () => __awaiter(this, void 0, void 0, function* () {
const tree = yield testing_1.runSchematic('preset', { name: 'proj', preset: 'angular-nest' }, projectTree);
expect(tree.exists('/apps/proj/src/app/app.component.ts')).toBe(true);
expect(tree.exists('/apps/api/src/app/app.controller.ts')).toBe(true);
expect(tree.exists('/libs/api-interfaces/src/lib/api-interfaces.ts')).toBe(true);
}));
it('should work with unnormalized names', () => __awaiter(this, void 0, void 0, function* () {
const tree = yield testing_1.runSchematic('preset', { name: 'myProj', preset: 'angular-nest' }, projectTree);
expect(tree.exists('/apps/my-proj/src/app/app.component.ts')).toBe(true);
expect(tree.exists('/apps/api/src/app/app.controller.ts')).toBe(true);
expect(tree.exists('/libs/api-interfaces/src/lib/api-interfaces.ts')).toBe(true);
}));
});
describe('--preset react-express', () => {
it('should create files', () => __awaiter(this, void 0, void 0, function* () {
const tree = yield testing_1.runSchematic('preset', { name: 'proj', preset: 'react-express' }, projectTree);
expect(tree.exists('/apps/proj/src/app/app.tsx')).toBe(true);
expect(tree.exists('/libs/api-interfaces/src/lib/api-interfaces.ts')).toBe(true);
expect(tree.exists('/apps/proj/.eslintrc')).toBe(true);
expect(tree.exists('/apps/api/.eslintrc')).toBe(true);
expect(tree.exists('/libs/api-interfaces/.eslintrc')).toBe(true);
}));
it('should work with unnormalized names', () => __awaiter(this, void 0, void 0, function* () {
const tree = yield testing_1.runSchematic('preset', { name: 'myProj', preset: 'react-express' }, projectTree);
expect(tree.exists('/apps/my-proj/src/app/app.tsx')).toBe(true);
expect(tree.exists('/libs/api-interfaces/src/lib/api-interfaces.ts')).toBe(true);
}));
});
});