@yolkai/nx-workspace
Version:
69 lines (68 loc) • 3.42 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("@yolkai/nx-workspace/testing");
const testing_2 = require("../../utils/testing");
const workspace_1 = require("@yolkai/nx-workspace/src/utils/workspace");
describe('Update 8.10.0', () => {
let tree;
beforeEach(() => __awaiter(this, void 0, void 0, function* () {
tree = schematics_1.Tree.empty();
tree = testing_1.createEmptyWorkspace(tree);
}));
it('should fix projects with invalid tslint configs', () => __awaiter(this, void 0, void 0, function* () {
tree = yield testing_2.callRule(schematics_1.chain([
workspace_1.updateWorkspace(workspace => {
workspace.projects.add({
name: 'proj-with-invalid-tslint',
root: 'proj-with-invalid-tslint'
});
}),
nx_workspace_1.updateJsonInTree('proj-with-invalid-tslint/tslint.json', () => ({
rules: []
}))
]), tree);
const result = yield testing_2.runMigration('fix-tslint-json', {}, tree);
expect(nx_workspace_1.readJsonInTree(result, 'proj-with-invalid-tslint/tslint.json').rules).toEqual({});
}));
it('should fix projects with valid tslint configs', () => __awaiter(this, void 0, void 0, function* () {
tree = yield testing_2.callRule(schematics_1.chain([
workspace_1.updateWorkspace(workspace => {
workspace.projects.add({
name: 'proj-with-valid-tslint',
root: 'proj-with-valid-tslint'
});
}),
nx_workspace_1.updateJsonInTree('proj-with-valid-tslint/tslint.json', () => ({
rules: {
rule: [true]
}
}))
]), tree);
const result = yield testing_2.runMigration('fix-tslint-json', {}, tree);
expect(nx_workspace_1.readJsonInTree(result, 'proj-with-valid-tslint/tslint.json').rules).toEqual({
rule: [true]
});
}));
it('should not add tslint configs to projects without tslint configs', () => __awaiter(this, void 0, void 0, function* () {
tree = yield testing_2.callRule(schematics_1.chain([
workspace_1.updateWorkspace(workspace => {
workspace.projects.add({
name: 'proj-without-tslint',
root: 'proj-without-tslint'
});
})
]), tree);
const result = yield testing_2.runMigration('fix-tslint-json', {}, tree);
expect(result.exists('proj-without-tslint/tslint.json')).toEqual(false);
}));
});