batchPrice.spec.js
846 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
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,
});
});
});