Refresh HiveGrid Cloud reference snapshot
This commit is contained in:
1 parent
5e99e14772
commit
7f88026f79
5955 files changed
+1177325
-188362
No files matched your search
@@ -0,0 +1,60 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
|
||||
import { getSeatPackage, seatPackageIds } from "./seat-packages.js";
|
||||
import { computeSeatUsage } from "./seat-usage.js";
|
||||
|
||||
const starter = getSeatPackage(seatPackageIds.starter);
|
||||
const team = getSeatPackage(seatPackageIds.team);
|
||||
|
||||
describe("computeSeatUsage", () => {
|
||||
it("reports no extra when both categories are within the included limit", () => {
|
||||
const result = computeSeatUsage({ package: starter, officeUsed: 2, fieldUsed: 3 });
|
||||
|
||||
expect(result.office).toMatchObject({ included: 2, used: 2, extra: 0, extraCostEur: 0, overLimit: false });
|
||||
expect(result.field).toMatchObject({ included: 5, used: 3, extra: 0, extraCostEur: 0, overLimit: false });
|
||||
expect(result.totalExtraCostEur).toBe(0);
|
||||
expect(result.hasOverage).toBe(false);
|
||||
});
|
||||
|
||||
it("computes extra seats and cost when the office category is over the limit", () => {
|
||||
// starter: 2 office included at 59 EUR/extra. 5 used => 3 extra => 177 EUR.
|
||||
const result = computeSeatUsage({ package: starter, officeUsed: 5, fieldUsed: 5 });
|
||||
|
||||
expect(result.office).toMatchObject({ included: 2, used: 5, extra: 3, extraPriceEur: 59, extraCostEur: 177, overLimit: true });
|
||||
expect(result.field).toMatchObject({ extra: 0, overLimit: false });
|
||||
expect(result.totalExtraCostEur).toBe(177);
|
||||
expect(result.hasOverage).toBe(true);
|
||||
});
|
||||
|
||||
it("computes extra cost across both categories at once", () => {
|
||||
// starter: office 3 used => 1 extra × 59 = 59; field 7 used => 2 extra × 25 = 50.
|
||||
const result = computeSeatUsage({ package: starter, officeUsed: 3, fieldUsed: 7 });
|
||||
|
||||
expect(result.office).toMatchObject({ extra: 1, extraCostEur: 59 });
|
||||
expect(result.field).toMatchObject({ extra: 2, extraCostEur: 50 });
|
||||
expect(result.totalExtraCostEur).toBe(109);
|
||||
expect(result.hasOverage).toBe(true);
|
||||
});
|
||||
|
||||
it("boundary: exactly at the included limit is not an overage", () => {
|
||||
const result = computeSeatUsage({ package: team, officeUsed: 5, fieldUsed: 15 });
|
||||
expect(result.hasOverage).toBe(false);
|
||||
expect(result.office.extra).toBe(0);
|
||||
expect(result.field.extra).toBe(0);
|
||||
});
|
||||
|
||||
it("clamps negative / non-finite used counts to zero", () => {
|
||||
const result = computeSeatUsage({ package: starter, officeUsed: -4, fieldUsed: Number.NaN });
|
||||
expect(result.office.used).toBe(0);
|
||||
expect(result.field.used).toBe(0);
|
||||
expect(result.hasOverage).toBe(false);
|
||||
});
|
||||
|
||||
it("bills extra seats at the discounted annual-SEPA price when requested", () => {
|
||||
// starter office extra list price 59 => annual-SEPA 53.1 per seat.
|
||||
const result = computeSeatUsage({ package: starter, officeUsed: 4, fieldUsed: 0, cadence: "annualSepa" });
|
||||
expect(result.office.extra).toBe(2);
|
||||
expect(result.office.extraPriceEur).toBeCloseTo(53.1, 5);
|
||||
expect(result.office.extraCostEur).toBeCloseTo(106.2, 5);
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user