Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 42 additions & 2 deletions e2e/application.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,11 @@ describe("application schematic", () => {

describe("with TypeScript (default)", () => {
let tree: UnitTestTree;
let packageJson: any;

beforeAll(async () => {
tree = await runner.runSchematic("application", { name: "my-app" });
packageJson = JSON.parse(tree.readContent("/my-app/package.json"));
});

it("should generate project files", () => {
Expand All @@ -23,14 +25,16 @@ describe("application schematic", () => {
});

it("should set the project name in package.json", () => {
const packageJson = JSON.parse(tree.readContent("/my-app/package.json"));
expect(packageJson.name).toBe("my-app");
});

it("should not include ecs-server by default", () => {
const packageJson = JSON.parse(tree.readContent("/my-app/package.json"));
expect(packageJson.devDependencies["@nanoforge-dev/ecs-server"]).toBeUndefined();
});

it("should not include pnpm config by default", () => {
expect(packageJson).not.toHaveProperty("pnpm");
});
});

describe("with JavaScript", () => {
Expand All @@ -50,6 +54,27 @@ describe("application schematic", () => {
});
});

describe("with JavaScript and no lint", () => {
let tree: UnitTestTree;

beforeAll(async () => {
tree = await runner.runSchematic("application", {
name: "js-no-lint-app",
language: "js",
lint: false,
});
});

it("should generate JS project files without lint files", () => {
expect(tree.files).toContain("/js-no-lint-app/package.json");
expect(tree.files).not.toContain("/js-no-lint-app/eslint.config.json");
expect(tree.files).not.toContain("/js-no-lint-app/prettier.config.json");
expect(tree.files).not.toContain("/js-no-lint-app/.prettierignore");
expect(tree.files).not.toContain("/js-no-lint-app/jsconfig.json");
expect(tree.files).not.toContain("/js-no-lint-app/tsconfig.json");
});
});

describe("with server enabled", () => {
let tree: UnitTestTree;

Expand Down Expand Up @@ -96,6 +121,21 @@ describe("application schematic", () => {
});
});

describe("with pnpm", () => {
it("should generate specifications of pnpm", async () => {
const tree = await runner.runSchematic("application", {
name: "pnpm-app",
packageManager: "pnpm",
server: true,
});
expect(tree.files).toContain("/pnpm-app/package.json");
const packageJson = JSON.parse(tree.readContent("/pnpm-app/package.json"));
expect(packageJson).toHaveProperty("pnpm", {
neverBuiltDependencies: [],
});
});
});

describe("with PascalCase name", () => {
it("should convert name to kebab-case", async () => {
const tree = await runner.runSchematic("application", {
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,8 @@
},
"dependencies": {
"@angular-devkit/core": "catalog:schematics",
"@angular-devkit/schematics": "catalog:schematics"
"@angular-devkit/schematics": "catalog:schematics",
"rxjs": "catalog:schematics"
},
"devDependencies": {
"@commitlint/cli": "catalog:ci",
Expand Down
Loading