Files
vimx/training/tests/pricing.test.ts
T
fukunee 3ff24e1ed5 Streamline training tasks and add debugging guide
Reorganize the README checklist: fold the standalone
Ex-command task into earlier tasks, give the outline panel
its own bindings (g o / Ctrl+Shift+O), and add a dedicated
debugging task with breakpoint, stepping, and fault-finding
drills anchored to real lines in the training app.

Annotate the training app sources and tests with Chinese
practice hints (multi-cursor, macro, text-object, and
breakpoint spots).

Drop the redundant root tsconfig, since training/tsconfig.json
already covers src and tests, and remove the stale
LEADERBOARD.md left over from the deleted challenge mode.
2026-09-09 23:54:48 +08:00

25 lines
808 B
TypeScript

// vitest 单测:pricing 相关用例,断点可设在 lineTotal / shippingCost 上
import { describe, expect, it } from "vitest";
import { round2, lineTotal, shippingCost } from "../src/pricing";
import { findProduct } from "../src/catalog";
describe("pricing", () => {
it("round2 保留两位小数", () => {
expect(round2(1.156)).toBe(1.16);
expect(round2(2.5)).toBe(2.5);
});
it("lineTotal 按数量计价(未税)", () => {
expect(lineTotal(findProduct("apple"), 3)).toBeCloseTo(4.5);
});
it("lineTotal 满 10 件打 95 折", () => {
expect(lineTotal(findProduct("apple"), 10)).toBeCloseTo(14.25);
});
it("shippingCost 满 50 免运费,否则收运费", () => {
expect(shippingCost(60)).toBe(0);
expect(shippingCost(49.99)).toBeCloseTo(4.99);
});
});