Files
vimx/training/tests/receipt.test.ts
T
fukunee 715ddb958a Rebuild training around a modular TS app
Replace the old exercise files (challenges, maze, sandbox, etc.)
with a runnable order/inventory TypeScript app under training/
that ships with unit tests, typecheck, lint, and format scripts.

Merge the full task checklist from TRAINING.md into README.md and
drop the obsolete docs and challenge files.

Add a root .gitignore for .zed, .reasonix, and build artifacts,
untrack the previously committed local configs, and fix the root
tsconfig to point at the new training sources.
2026-09-09 23:34:48 +08:00

17 lines
575 B
TypeScript

import { describe, expect, it } from "vitest";
import { Receipt } from "../src/receipt";
import { createOrder } from "../src/orders";
describe("Receipt", () => {
it("lines() 返回订单每一行的描述", () => {
const order = createOrder([{ productId: "apple", quantity: 3 }]);
const receipt = new Receipt(order);
expect(receipt.lines()).toEqual(["Apple x3 $4.50"]);
});
it("total() 等于订单 total", () => {
const order = createOrder([{ productId: "bread", quantity: 1 }]);
expect(new Receipt(order).total()).toBe(order.total);
});
});