@yolkai/nx-workspace
Version:
60 lines (59 loc) • 3.01 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 nx_workspace_1 = require("@yolkai/nx-workspace");
const testing_1 = require("../../utils/testing");
describe('workspace', () => {
let projectTree;
beforeEach(() => {
projectTree = schematics_1.Tree.empty();
});
it('should create files', () => __awaiter(this, void 0, void 0, function* () {
const tree = yield testing_1.runSchematic('workspace', { name: 'proj' }, projectTree);
expect(tree.exists('/nx.json')).toBe(true);
expect(tree.exists('/workspace.json')).toBe(true);
expect(tree.exists('/.prettierrc')).toBe(true);
expect(tree.exists('/.prettierignore')).toBe(true);
}));
it('should create nx.json', () => __awaiter(this, void 0, void 0, function* () {
const tree = yield testing_1.runSchematic('workspace', { name: 'proj' }, projectTree);
const nxJson = nx_workspace_1.readJsonInTree(tree, '/nx.json');
expect(nxJson).toEqual({
npmScope: 'proj',
implicitDependencies: {
'workspace.json': '*',
'package.json': '*',
'tsconfig.json': '*',
'tslint.json': '*',
'nx.json': '*'
},
projects: {}
});
}));
it('should recommend vscode extensions', () => __awaiter(this, void 0, void 0, function* () {
const tree = yield testing_1.runSchematic('workspace', { name: 'proj' }, projectTree);
const recommendations = nx_workspace_1.readJsonInTree(tree, '/.vscode/extensions.json').recommendations;
expect(recommendations).toEqual([
'ms-vscode.vscode-typescript-tslint-plugin',
'esbenp.prettier-vscode'
]);
}));
it('should recommend vscode extensions (angular)', () => __awaiter(this, void 0, void 0, function* () {
const tree = yield testing_1.runSchematic('workspace', { name: 'proj', cli: 'angular' }, projectTree);
const recommendations = nx_workspace_1.readJsonInTree(tree, '/.vscode/extensions.json').recommendations;
expect(recommendations).toEqual([
'nrwl.angular-console',
'angular.ng-template',
'ms-vscode.vscode-typescript-tslint-plugin',
'esbenp.prettier-vscode'
]);
}));
});