batchPrice.spec.js 846 Bytes
import {
	getBatchPriceSelectionSummary,
	hasUnsupportedPurchaseCostType,
} from "./batchPrice";

describe("purchase batch price", () => {
	it("rejects selections containing an automatic-cost record", () => {
		expect(hasUnsupportedPurchaseCostType([
			{ purchaseCostType: 0 },
			{ purchaseCostType: "1" },
		])).toBe(true);
		expect(hasUnsupportedPurchaseCostType([
			{ purchaseCostType: 0 },
			{ purchaseCostType: "0" },
		])).toBe(false);
	});

	it("counts selected goods and distinct merchant numbers", () => {
		expect(getBatchPriceSelectionSummary([
			{
				id: 1,
				merchantRefList: [
					{ merchantId: 1001 },
					{ merchantNo: "1002" },
				],
			},
			{
				id: 2,
				merchantRefList: [
					{ merchantId: "1001" },
					{ merchantId: 1003 },
				],
			},
		])).toEqual({
			goodsCount: 2,
			merchantCount: 3,
		});
	});
});