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
6 changes: 5 additions & 1 deletion apps/nextjs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,10 @@
"lint": "biome lint .",
"check": "biome check .",
"fix": "biome check --write .",
"start": "next start"
"start": "next start",
"test": "vitest run",
"test:watch": "vitest watch",
"test:coverage": "vitest run --coverage"
},
"peerDependencies": {
"@packages/libs": "workspace:*",
Expand All @@ -31,6 +34,7 @@
},
"devDependencies": {
"@packages/typescript-config": "workspace:*",
"@packages/test": "workspace:*",
"@types/node": "^24.0.3",
"@types/react": "^19.1.8",
"@types/react-dom": "^19.1.6",
Expand Down
56 changes: 56 additions & 0 deletions apps/nextjs/src/__TESTS__/test.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
import { describe, expect, it } from "vitest";

describe("Next.js Application", () => {
describe("Basic Functionality", () => {
it("should have a working test environment", () => {
expect(process.env.NODE_ENV).toBeDefined();
expect(typeof process.env.NODE_ENV).toBe("string");
});

it("should support async operations", async () => {
const result = await Promise.resolve("test");
expect(result).toBe("test");
});
});

describe("TypeScript Support", () => {
it("should handle type assertions correctly", () => {
const value: unknown = "hello world";
const typedValue = value as string;

expect(typeof typedValue).toBe("string");
expect(typedValue.length).toBeGreaterThan(0);
});

it("should work with interfaces", () => {
interface TestData {
id: number;
name: string;
}

const data: TestData = { id: 1, name: "test" };

expect(data.id).toBe(1);
expect(data.name).toBe("test");
});
});

describe("Array Operations", () => {
it("should handle array methods", () => {
const numbers = [1, 2, 3, 4, 5];
const doubled = numbers.map((n) => n * 2);
const filtered = doubled.filter((n) => n > 5);

expect(doubled).toEqual([2, 4, 6, 8, 10]);
expect(filtered).toEqual([6, 8, 10]);
});

it("should work with array destructuring", () => {
const [first, second, ...rest] = [1, 2, 3, 4, 5];

expect(first).toBe(1);
expect(second).toBe(2);
expect(rest).toEqual([3, 4, 5]);
});
});
});
4 changes: 4 additions & 0 deletions apps/nextjs/vitest.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import baseConfig from "@packages/test/base-vitest.config";
import { defineConfig, mergeConfig } from "vitest/config";

export default mergeConfig(baseConfig, defineConfig({}));
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
"clean": "turbo clean && rm -rf node_modules",
"type-check": "turbo type-check",
"test": "turbo test",
"test:watch": "turbo test:watch",
"test:coverage": "turbo test:coverage",
"prepare": "husky"
},
"devDependencies": {
Expand Down
6 changes: 5 additions & 1 deletion packages/ddd-kit/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,14 @@
"main": "src/index.ts",
"types": "src/index.ts",
"scripts": {
"build": "tsc"
"build": "tsc",
"test": "vitest run",
"test:watch": "vitest watch",
"test:coverage": "vitest run --coverage"
},
"devDependencies": {
"@packages/typescript-config": "workspace:*",
"@packages/test": "workspace:*",
"typescript": "^5.8.3"
}
}
84 changes: 84 additions & 0 deletions packages/ddd-kit/src/__TESTS__/test.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
import { describe, expect, it } from "vitest";

describe("ddd-kit", () => {
describe("Core Functionality", () => {
it("should validate basic DDD principles", () => {
const domainValue = "business-rule";
const isValid = domainValue.includes("business");

expect(isValid).toBe(true);
expect(domainValue).toContain("rule");
});

it("should handle domain entities correctly", () => {
const entity = {
id: "user-123",
name: "John Doe",
email: "john@example.com",
};

expect(entity.id).toBeDefined();
expect(entity.name).toHaveLength(8);
expect(entity.email).toMatch(/^[^\s@]+@[^\s@]+\.[^\s@]+$/);
});

it("should support value objects", () => {
const email = "test@domain.com";
const isValidEmail = /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(email);

expect(isValidEmail).toBe(true);
expect(email).toContain("@");
expect(email).toContain(".");
});
});

describe("Domain Logic", () => {
it("should enforce business rules", () => {
const age = 25;
const isAdult = age >= 18;
const canVote = age >= 18;

expect(isAdult).toBe(true);
expect(canVote).toBe(true);
expect(age).toBeGreaterThanOrEqual(18);
});

it("should handle domain events", () => {
const events = ["UserCreated", "OrderPlaced", "PaymentProcessed"];
const hasUserEvent = events.includes("UserCreated");
const eventCount = events.length;

expect(hasUserEvent).toBe(true);
expect(eventCount).toBe(3);
expect(events).toContain("OrderPlaced");
});
});

describe("Repository Pattern", () => {
it("should support data persistence abstraction", async () => {
const mockData = { id: 1, name: "Test Item" };
const saveOperation = Promise.resolve(mockData);

const result = await saveOperation;

expect(result).toEqual(mockData);
expect(result.id).toBe(1);
expect(result.name).toBe("Test Item");
});

it("should handle repository queries", async () => {
const users = [
{ id: 1, name: "Alice" },
{ id: 2, name: "Bob" },
];

const findUser = (id: number) =>
Promise.resolve(users.find((u) => u.id === id));

const user = await findUser(1);

expect(user).toBeDefined();
expect(user?.name).toBe("Alice");
});
});
});
12 changes: 12 additions & 0 deletions packages/test/base-vitest.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { defineConfig } from "vitest/config";

export default defineConfig({
test: {
exclude: ["node_modules", "dist"],
environment: "node",
coverage: {
provider: "v8",
include: ["src/**/*.ts"],
},
},
});
18 changes: 18 additions & 0 deletions packages/test/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"name": "@packages/test",
"version": "0.0.0",
"private": true,
"main": "src/index.ts",
"types": "src/index.ts",
"scripts": {
"format": "biome format . --write",
"lint": "biome lint .",
"check": "biome check .",
"fix": "biome check --write ."
},
"devDependencies": {
"vitest": "^3.2.4",
"@packages/typescript-config": "workspace:*",
"typescript": "^5.8.3"
}
}
Loading