Skip to content

Commit 7b0d992

Browse files
committed
test(templates): add igc-ts checks, minor update
1 parent 10ee6b2 commit 7b0d992

File tree

4 files changed

+59
-5
lines changed

4 files changed

+59
-5
lines changed

spec/templates/angular-spec.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
1-
import { Framework, Util } from "@igniteui/cli-core";
1+
import { App, Framework, Util } from "@igniteui/cli-core";
22

33
const templatesLocation = "../../packages/cli/templates/angular";
44

55
describe("Angular templates", () => {
6+
beforeAll(() => {
7+
App.initialize();
8+
});
69

710
it("Templates should have IDs", async function() {
811
const angularFramework = require(templatesLocation);
@@ -27,7 +30,9 @@ describe("Angular templates", () => {
2730
// pass some __path__ so those won't match
2831
expect(
2932
(Util as any).validateTemplate(element["rootPath"] + "/files", target["rootPath"] + "/files", {path: "1"}, {})
30-
).toBeTruthy(`Template ${element.id} can overwrite ${target.id}`);
33+
)
34+
.withContext(`Template ${element.id} can overwrite ${target.id}`)
35+
.toBeTruthy();
3136
}
3237
}
3338
});

spec/templates/jquery-spec.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,20 @@
1+
import { App } from "@igniteui/cli-core";
12

23
const templatesLocation = "../../packages/cli/templates/jquery";
34

45
describe("jQuery templates", () => {
6+
beforeAll(() => {
7+
App.initialize();
8+
});
59

610
it("Templates should have IDs", async function() {
711
const jQueryFramework = require(templatesLocation);
812
expect(jQueryFramework.projectLibraries[0]).toBeDefined();
913

1014
for (const template of jQueryFramework.projectLibraries[0].templates) {
11-
expect(template.id).toBeDefined("No ID: " + template.name);
15+
expect(template.id)
16+
.withContext("No ID: " + template.name)
17+
.toBeDefined();
1218
}
1319
});
1420

spec/templates/react-spec.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
1-
import { Framework, Util } from "@igniteui/cli-core";
1+
import { App, Framework, Util } from "@igniteui/cli-core";
22

33
const templatesLocation = "../../packages/cli/templates/react";
44
describe("React templates", () => {
5+
beforeAll(() => {
6+
App.initialize();
7+
});
58

69
it("Templates should have IDs", async function() {
710
const reactFramework = require(templatesLocation);
@@ -22,7 +25,9 @@ describe("React templates", () => {
2225
// pass some __path__ so those won't match
2326
expect(
2427
(Util as any).validateTemplate(element["rootPath"] + "/files", target["rootPath"] + "/files", {path: "1"}, {})
25-
).toBeTruthy(`Template ${element.id} can overwrite ${target.id}`);
28+
)
29+
.withContext(`Template ${element.id} can overwrite ${target.id}`)
30+
.toBeTruthy();
2631
}
2732
}
2833
});
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
import { App, Framework, Util } from "@igniteui/cli-core";
2+
3+
const templatesLocation = "../../packages/cli/templates/webcomponents";
4+
describe("Web Components templates", () => {
5+
beforeAll(() => {
6+
App.initialize();
7+
});
8+
9+
it("Templates should have IDs", async function() {
10+
const wcFramework = require(templatesLocation);
11+
expect(wcFramework.projectLibraries[0]).toBeDefined();
12+
13+
for (const template of wcFramework.projectLibraries[0].templates) {
14+
expect(template.id)
15+
.withContext("No ID: " + template.name + " type: " + template.projectType)
16+
.toBeDefined();
17+
}
18+
});
19+
20+
it("Igc Templates should have no internal collisions", async () => {
21+
const wcFramework: Framework = require(templatesLocation);
22+
const projLibrary = wcFramework.projectLibraries.find(x => x.projectType === "igc-ts");
23+
expect(projLibrary).toBeDefined();
24+
25+
for (let i = 0; i < projLibrary.templates.length; i++) {
26+
const element = projLibrary.templates[i];
27+
for (let j = i + 1; j < projLibrary.templates.length; j++) {
28+
const target = projLibrary.templates[j];
29+
// pass some __path__ so those won't match
30+
expect(
31+
(Util as any).validateTemplate(element["rootPath"] + "/files", target["rootPath"] + "/files", {path: "1"}, {})
32+
)
33+
.withContext(`Template ${element.id} can overwrite ${target.id}`)
34+
.toBeTruthy();
35+
}
36+
}
37+
});
38+
});

0 commit comments

Comments
 (0)