@yolkai/nx-workspace
Version:
91 lines (90 loc) • 3.08 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
const assert_workspace_validity_1 = require("./assert-workspace-validity");
describe('assertWorkspaceValidity', () => {
let mockNxJson;
let mockWorkspaceJson;
beforeEach(() => {
mockNxJson = {
projects: {
app1: {
tags: []
},
'app1-e2e': {
tags: []
},
app2: {
tags: []
},
'app2-e2e': {
tags: []
},
lib1: {
tags: []
},
lib2: {
tags: []
}
}
};
mockWorkspaceJson = {
projects: {
app1: {},
'app1-e2e': {},
app2: {},
'app2-e2e': {},
lib1: {},
lib2: {}
}
};
});
it('should not throw for a valid workspace', () => {
assert_workspace_validity_1.assertWorkspaceValidity(mockWorkspaceJson, mockNxJson);
});
it('should throw for a missing project in workspace.json', () => {
delete mockWorkspaceJson.projects.app1;
try {
assert_workspace_validity_1.assertWorkspaceValidity(mockWorkspaceJson, mockNxJson);
fail('Did not throw');
}
catch (e) {
expect(e.message).toContain('projects are missing in');
}
});
it('should throw for a missing project in nx.json', () => {
delete mockNxJson.projects.app1;
try {
assert_workspace_validity_1.assertWorkspaceValidity(mockWorkspaceJson, mockNxJson);
fail('Did not throw');
}
catch (e) {
expect(e.message).toContain('projects are missing in nx.json');
}
});
it('should throw for an invalid top-level implicit dependency', () => {
mockNxJson.implicitDependencies = {
'README.md': ['invalidproj']
};
try {
assert_workspace_validity_1.assertWorkspaceValidity(mockWorkspaceJson, mockNxJson);
fail('Did not throw');
}
catch (e) {
expect(e.message).toContain('implicitDependencies specified in nx.json are invalid');
expect(e.message).toContain(' README.md');
expect(e.message).toContain(' invalidproj');
}
});
it('should throw for an invalid project-level implicit dependency', () => {
mockNxJson.projects.app2.implicitDependencies = ['invalidproj'];
try {
assert_workspace_validity_1.assertWorkspaceValidity(mockWorkspaceJson, mockNxJson);
fail('Did not throw');
}
catch (e) {
expect(e.message).toContain('implicitDependencies specified in nx.json are invalid');
expect(e.message).toContain(' app2');
expect(e.message).toContain(' invalidproj');
}
});
});