Skip to content

Commit 0756d02

Browse files
authored
refactor: remove leftover wrappers AngularTemplate and related tests (#1556)
1 parent 8096fe0 commit 0756d02

File tree

3 files changed

+1
-457
lines changed

3 files changed

+1
-457
lines changed

packages/cli/lib/templates/AngularTemplate.ts

Lines changed: 0 additions & 166 deletions
This file was deleted.

spec/unit/add-spec.ts

Lines changed: 1 addition & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import * as path from "path";
66
import * as ts from "typescript";
77
import { default as addCmd } from "../../packages/cli/lib/commands/add";
88
import { PromptSession } from "../../packages/cli/lib/PromptSession";
9-
import { AngularTemplate } from "../../packages/cli/lib/templates/AngularTemplate";
109
import { resetSpy } from "../helpers/utils";
1110

1211
function createMockBaseTemplate(): BaseTemplate {
@@ -312,75 +311,6 @@ describe("Unit - Add command", () => {
312311
expect(addCmd.templateManager.updateProjectConfiguration).toHaveBeenCalledTimes(1);
313312
});
314313

315-
it("Should properly accept module args when passed - Angular Wrappers", async () => {
316-
const mockProjectConfig = {
317-
project: {
318-
framework: "angular",
319-
theme: "infragistics"
320-
}
321-
} as unknown as Config;
322-
spyOn(TypeScriptUtils, "getFileSource").and.returnValue(
323-
ts.createSourceFile("test-file-name", ``, ts.ScriptTarget.Latest, true)
324-
);
325-
const routeSpy = spyOn(AngularTypeScriptFileUpdate.prototype, "addRoute");
326-
// const declarationSpy = spyOn(AngularTypeScriptFileUpdate.prototype, "addDeclaration").and.callThrough();
327-
const ngMetaSpy = spyOn(AngularTypeScriptFileUpdate.prototype, "addNgModuleMeta");
328-
const finalizeSpy = spyOn(AngularTypeScriptFileUpdate.prototype, "finalize");
329-
const mockTemplate = new AngularTemplate("test");
330-
mockTemplate.packages = [];
331-
mockTemplate.dependencies = [];
332-
333-
const directoryPath = path.join("My/Example/Path");
334-
spyOn(process, "cwd").and.returnValue(directoryPath);
335-
spyOn(mockTemplate, "generateConfig");
336-
spyOn(Util, "processTemplates").and.returnValue(Promise.resolve(true));
337-
spyOn(mockTemplate, "registerInProject").and.callThrough();
338-
spyOn(Util, "directoryExists").and.returnValue(true);
339-
// const sourceFilesSpy = spyOn<any>(mockTemplate, "ensureSourceFiles");
340-
const mockLibrary = jasmine.createSpyObj("frameworkLibrary", ["hasTemplate", "getTemplateById"]);
341-
mockLibrary.hasTemplate.and.returnValue(true);
342-
mockLibrary.getTemplateById.and.returnValue(mockTemplate);
343-
addCmd.templateManager = jasmine.createSpyObj("TemplateManager", {
344-
getFrameworkById: {},
345-
getProjectLibrary: mockLibrary,
346-
updateProjectConfiguration: () => {}
347-
});
348-
spyOn(ProjectConfig, "getConfig").and.returnValue(mockProjectConfig);
349-
spyOn(ProjectConfig, "hasLocalConfig").and.returnValue(true);
350-
spyOn(addCmd, "addTemplate").and.callThrough();
351-
spyOn(PackageManager, "flushQueue").and.returnValue(Promise.resolve());
352-
spyOn(PackageManager, "ensureIgniteUISource");
353-
await addCmd.handler({
354-
name: "test-file-name", template: "CustomTemplate",
355-
module: "myCustomModule/my-custom-module.module.ts",
356-
_: ["add"],
357-
$0: "add"
358-
});
359-
expect(addCmd.addTemplate).toHaveBeenCalledWith(
360-
"test-file-name", mockTemplate,
361-
jasmine.objectContaining({ modulePath: "myCustomModule/my-custom-module.module.ts" })
362-
);
363-
expect(PackageManager.flushQueue).toHaveBeenCalled();
364-
expect(mockTemplate.generateConfig).toHaveBeenCalledTimes(1);
365-
expect(mockTemplate.generateConfig).toHaveBeenCalledWith(
366-
"test-file-name",
367-
jasmine.objectContaining({ modulePath: "myCustomModule/my-custom-module.module.ts" })
368-
);
369-
expect(mockTemplate.registerInProject).toHaveBeenCalledTimes(1);
370-
expect(mockTemplate.registerInProject).toHaveBeenCalledWith(
371-
directoryPath, "test-file-name",
372-
jasmine.objectContaining({ modulePath: "myCustomModule/my-custom-module.module.ts" }));;
373-
expect(routeSpy).toHaveBeenCalledTimes(1);
374-
expect(ngMetaSpy).toHaveBeenCalledTimes(1);
375-
expect(ngMetaSpy).toHaveBeenCalledWith({
376-
declare: ["TestFileNameComponent"],
377-
from: "../components/test-file-name/test-file-name.component",
378-
export: [ 'TestFileNameComponent' ]
379-
});
380-
expect(finalizeSpy).toHaveBeenCalledTimes(2);
381-
expect(addCmd.templateManager.updateProjectConfiguration).toHaveBeenCalledTimes(1);
382-
});
383-
384314
it("Should properly accept skip-route args when passed", async () => {
385315
const mockProjectConfig = {
386316
project: {
@@ -442,7 +372,7 @@ describe("Unit - Add command", () => {
442372
spyOn(Util, "fileExists").and.returnValue(false);
443373
spyOn(Util, "error");
444374
const wrongPath = "myCustomModule/my-custom-module.module.ts";
445-
addCmd.addTemplate("test-file-name", new AngularTemplate(__dirname), { modulePath: wrongPath });
375+
addCmd.addTemplate("test-file-name", new IgniteUIForAngularTemplate(__dirname), { modulePath: wrongPath });
446376
expect(Util.fileExists).toHaveBeenCalledTimes(1);
447377
expect(Util.error).toHaveBeenCalledTimes(1);
448378
expect(Util.error).toHaveBeenCalledWith(`Wrong module path provided: ${wrongPath}. No components were added!`);

0 commit comments

Comments
 (0)