Skip to content

Commit 09e9a0e

Browse files
committed
test: update more tests after project type removal
1 parent 7e07f3c commit 09e9a0e

3 files changed

Lines changed: 13 additions & 95 deletions

File tree

spec/acceptance/add-spec.ts

Lines changed: 0 additions & 83 deletions
Original file line numberDiff line numberDiff line change
@@ -157,89 +157,6 @@ describe("Add command", () => {
157157
fs.unlinkSync(ProjectConfig.configFile);
158158
});
159159

160-
it("Should correctly add Angular template", async () => {
161-
const mockConfig = {
162-
project: {
163-
framework: "angular",
164-
projectType: "igx-ts",
165-
components: [],
166-
}
167-
} as unknown as Config;
168-
169-
spyOn(ProjectConfig, "globalConfig").and.returnValue(mockConfig);
170-
171-
fs.writeFileSync(ProjectConfig.configFile, JSON.stringify({
172-
project: mockConfig
173-
}));
174-
fs.mkdirSync(`./src`);
175-
fs.mkdirSync(`./src/app`);
176-
fs.writeFileSync("src/app/app-routing-module.ts", "const routes: Routes = [];");
177-
fs.writeFileSync("src/app/app-module.ts", `@NgModule({
178-
declarations: [
179-
App,
180-
HomeComponent
181-
],
182-
imports: [ BrowserModule ],
183-
bootstrap: [App]
184-
})
185-
export class AppModule { }`);
186-
await cli.run(["add", "grid", "Test view"]);
187-
188-
expect(console.error).toHaveBeenCalledTimes(0);
189-
expect(console.log).toHaveBeenCalledWith(jasmine.stringMatching(/View 'Test view' added\s*/));
190-
191-
expect(fs.existsSync("./src/app/components/test-view")).toBeTruthy();
192-
const componentPath = "./src/app/components/test-view/test-view.component.ts";
193-
expect(fs.existsSync(componentPath)).toBeTruthy();
194-
// file contents:
195-
expect(fs.readFileSync(componentPath, "utf-8")).toContain("export class TestViewComponent");
196-
expect(fs.readFileSync("src/app/app-routing-module.ts", "utf-8").replace(/\s/g, "")).toBe(
197-
`import { TestViewComponent } from "./components/test-view/test-view.component";
198-
const routes: Routes = [{ path: "test-view", component: TestViewComponent, data: { text: "Test view" } }];
199-
`.replace(/\s/g, "")
200-
);
201-
expect(fs.readFileSync("src/app/app-module.ts", "utf-8").replace(/\s/g, "")).toBe(
202-
`import { TestViewComponent } from "./components/test-view/test-view.component";
203-
@NgModule({
204-
declarations: [
205-
App,
206-
HomeComponent,
207-
TestViewComponent
208-
],
209-
imports: [ BrowserModule ],
210-
bootstrap: [App]
211-
})
212-
export class AppModule {
213-
}
214-
`.replace(/\s/g, "")
215-
);
216-
fs.unlinkSync("./src/app/components/test-view/test-view.component.ts");
217-
fs.rmSync("./src", { recursive: true, force: true });
218-
219-
fs.unlinkSync(ProjectConfig.configFile);
220-
221-
let expectedPrams: GoogleAnalyticsParameters = {
222-
t: "screenview",
223-
cd: "Add"
224-
};
225-
expect(GoogleAnalytics.post).toHaveBeenCalledWith(expectedPrams);
226-
227-
expectedPrams = {
228-
t: "event",
229-
ec: "$ig add",
230-
ea: "template id: grid; file name: Test view",
231-
cd1: "angular",
232-
cd2: "igx-ts",
233-
cd5: "Data Grids",
234-
cd7: "grid",
235-
cd8: "Grid",
236-
cd11: false,
237-
cd14: undefined
238-
};
239-
expect(GoogleAnalytics.post).toHaveBeenCalledWith(expectedPrams);
240-
expect(GoogleAnalytics.post).toHaveBeenCalledTimes(2);
241-
});
242-
243160
for (const igxPackage of [NPM_ANGULAR, FEED_ANGULAR]) {
244161
it(`Should correctly add Ignite UI for Angular template - ${igxPackage}`, async () => {
245162
const mockConfig = {} as unknown as Config;

spec/unit/TemplateManager-spec.ts

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ import { IgniteUIForAngularTemplate } from "@igniteui/angular-templates";
22
import { ComponentGroup, Config, Framework, ProjectConfig, Util } from "@igniteui/cli-core";
33
import * as path from "path";
44
import { TemplateManager } from "../../packages/cli/lib/TemplateManager";
5-
import { AngularTemplate } from "../../packages/cli/lib/templates/AngularTemplate";
65
import { jQueryTemplate } from "../../packages/cli/lib/templates/jQueryTemplate";
76
import { ReactTemplate } from "../../packages/cli/lib/templates/ReactTemplate";
7+
import { IgniteUIForWebComponentsTemplate } from "../../packages//cli/lib/templates/IgniteUIForWebComponentsTemplate";
88
import { mockProLibFactory } from "../helpers/mocks";
99
import { resetSpy } from "../helpers/utils";
1010

@@ -165,21 +165,22 @@ describe("Unit - Template manager", () => {
165165
});
166166

167167
it("Should load/create/register diff types of external custom Templates", async () => {
168-
spyOn(Util, "getDirectoryNames").and.returnValue(["jquery", "react", "angular"]);
168+
spyOn(Util, "getDirectoryNames").and.returnValue(["jquery", "react", "angular", "webcomponents"]);
169169
const templates = [
170170
"file:/template/jquery/js",
171171
"file:/template/react/es6",
172-
"path:/template/angular/ig-ts",
172+
"path:/template/webcomponents/igc-ts",
173173
"/template/angular/igx-ts"
174174
];
175175
const mockProjectConfig = { customTemplates: templates } as unknown as Config;
176176
spyOn(ProjectConfig, "getConfig").and.returnValue(mockProjectConfig);
177177
spyOn(Util, "directoryExists").and.returnValue(true);
178178
spyOn(Util, "fileExists").and.returnValue(true);
179179
mockProjLibs = {
180-
angular: [ mockProLibFactory("ig-ts"), mockProLibFactory("igx-ts")],
180+
angular: [ mockProLibFactory("igx-ts")],
181181
jquery: [ mockProLibFactory("js") ],
182-
react: [ mockProLibFactory("es6") ]
182+
react: [ mockProLibFactory("es6") ],
183+
webcomponents: [ mockProLibFactory("igc-ts") ],
183184
};
184185
customRequire = {
185186
require: modulePath => {
@@ -214,14 +215,14 @@ describe("Unit - Template manager", () => {
214215
expect(mockProjLibs.react[0].registerTemplate).toHaveBeenCalledWith(
215216
jasmine.objectContaining(template("react", "es6"))
216217
);
218+
expect(mockProjLibs.webcomponents[0].registerTemplate).toHaveBeenCalledTimes(1);
219+
expect(mockProjLibs.webcomponents[0].registerTemplate).toHaveBeenCalledWith(jasmine.any(IgniteUIForWebComponentsTemplate));
220+
expect(mockProjLibs.webcomponents[0].registerTemplate).toHaveBeenCalledWith(
221+
jasmine.objectContaining(template("webcomponents", "igc-ts"))
222+
);
217223
expect(mockProjLibs.angular[0].registerTemplate).toHaveBeenCalledTimes(1);
218-
expect(mockProjLibs.angular[0].registerTemplate).toHaveBeenCalledWith(jasmine.any(AngularTemplate));
224+
expect(mockProjLibs.angular[0].registerTemplate).toHaveBeenCalledWith(jasmine.any(IgniteUIForAngularTemplate));
219225
expect(mockProjLibs.angular[0].registerTemplate).toHaveBeenCalledWith(
220-
jasmine.objectContaining(template("angular", "ig-ts"))
221-
);
222-
expect(mockProjLibs.angular[1].registerTemplate).toHaveBeenCalledTimes(1);
223-
expect(mockProjLibs.angular[1].registerTemplate).toHaveBeenCalledWith(jasmine.any(IgniteUIForAngularTemplate));
224-
expect(mockProjLibs.angular[1].registerTemplate).toHaveBeenCalledWith(
225226
jasmine.objectContaining(template("angular", "igx-ts"))
226227
);
227228
});

spec/unit/Util-spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ describe("Unit - Util", () => {
5252
expect(Util.getAvailableName(defaultComponentName, false, "jQuery")).toEqual("grid 1");
5353
expect(Util.getAvailableName(defaultComponentName, false, "React")).toEqual("grid 1");
5454
expect(Util.getAvailableName(defaultComponentName, false, "Angular", "igx-ts")).toEqual("grid 1");
55-
expect(Util.directoryExists).toHaveBeenCalledTimes(10);
55+
expect(Util.directoryExists).toHaveBeenCalledTimes(8);
5656
});
5757

5858
it("should read the existing component view name and return incremented view name ", () => {

0 commit comments

Comments
 (0)