Files
at-mintel/packages/acquisition/test/pricing.test.ts
Marc Mintel 9e4e296e3b
Some checks failed
Monorepo Pipeline / 🧪 Quality Assurance (push) Failing after 11s
Monorepo Pipeline / 🚀 Release (push) Has been skipped
Monorepo Pipeline / 🐳 Build Directus (Base) (push) Has been skipped
Monorepo Pipeline / 🐳 Build Gatekeeper (Product) (push) Has been skipped
Monorepo Pipeline / 🐳 Build Build-Base (push) Has been skipped
Monorepo Pipeline / 🐳 Build Production Runtime (push) Has been skipped
feat: adds aquisition extension to cms
2026-02-10 21:30:23 +01:00

60 lines
2.3 KiB
TypeScript

import { describe, it, expect } from "vitest";
import { calculateTotals, calculatePositions } from "../src/logic/pricing/calculator.js";
import { PRICING, initialState } from "../src/logic/pricing/constants.js";
import { FormState } from "../src/logic/pricing/types.js";
describe("Pricing Logic", () => {
it("should calculate base website price correctly", () => {
const state: FormState = {
...initialState,
projectType: "website",
selectedPages: [] // Clear for base test
};
const totals = calculateTotals(state, PRICING);
expect(totals.totalPrice).toBe(PRICING.BASE_WEBSITE);
});
it("should add page costs correctly", () => {
const state: FormState = {
...initialState,
projectType: "website",
selectedPages: [], // Clear for clean test
otherPagesCount: 5
};
const totals = calculateTotals(state, PRICING);
expect(totals.totalPrice).toBe(PRICING.BASE_WEBSITE + (5 * PRICING.PAGE));
});
it("should apply multi-language multiplier", () => {
const state: FormState = {
...initialState,
projectType: "website",
selectedPages: [], // Clear for clean test
languagesList: ["Deutsch", "Englisch"]
};
const totals = calculateTotals(state, PRICING);
expect(totals.totalPrice).toBe(Math.round(PRICING.BASE_WEBSITE * 1.2));
});
it("should generate correct positions for a website", () => {
const state: FormState = {
...initialState,
projectType: "website",
selectedPages: ["Home"],
otherPagesCount: 2
};
const positions = calculatePositions(state, PRICING);
// Find "Fundament" position (Das technische Fundament)
const basePos = positions.find(p => p.title.includes("Fundament"));
expect(basePos).toBeDefined();
expect(basePos?.price).toBe(PRICING.BASE_WEBSITE);
// Find "Individuelle Seiten" position
const pagesPos = positions.find(p => p.title.includes("Seiten"));
expect(pagesPos).toBeDefined();
expect(pagesPos?.qty).toBe(3); // 1 selected + 2 other
expect(pagesPos?.price).toBe(3 * PRICING.PAGE);
});
});