stockManage.spec.js
1.98 KB
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
import mockRequest from "./request";
import {
exportStockMoveTemplate,
getStockMoveLogPage,
importStockMove,
listUpgradeGoodsSimple,
moveMerchantGoodsStock,
} from "./stockManage";
jest.mock("./request", () => jest.fn(data => Promise.resolve(data)));
describe("stock move api", () => {
beforeEach(() => {
mockRequest.mockClear();
});
it("queries light-modification products for the target UID selector", async () => {
await listUpgradeGoodsSimple({
currentPage: 1,
pageSize: 20,
commodityCode: "UID",
productType: 1,
});
expect(mockRequest).toHaveBeenCalledWith({
currentPage: 1,
pageSize: 20,
commodityCode: "UID",
productType: 1,
method: "dj.api.smartcarlife.productManager.listUpgradeGoodsSimple",
}, "post");
});
it("submits all identifiers required by a single stock move", async () => {
await moveMerchantGoodsStock({
upgradeGoodsId: 1,
yqMerchantId: 2,
targetUpgradeGoodsId: 3,
});
expect(mockRequest).toHaveBeenCalledWith({
upgradeGoodsId: 1,
yqMerchantId: 2,
targetUpgradeGoodsId: 3,
method: "dj.api.smartcarlife.MerchantGoodsStockMonthReport.stockMove",
}, "post", [], { useResponseMessage: true });
});
it("uploads the batch file without including it in the signature", async () => {
const file = { name: "stock.xlsx" };
await importStockMove({ file });
expect(mockRequest).toHaveBeenCalledWith({
file,
method: "dj.api.smartcarlife.MerchantGoodsStockMonthReport.stockMove.import",
}, "post", ["file"]);
});
it("exposes template and log endpoints", async () => {
await exportStockMoveTemplate();
expect(mockRequest).toHaveBeenLastCalledWith({
method: "dj.api.smartcarlife.MerchantGoodsStockMonthReport.stockMove.template.export",
}, "post");
await getStockMoveLogPage({ upgradeGoodsId: 1, yqMerchantId: 2 });
expect(mockRequest).toHaveBeenLastCalledWith({
upgradeGoodsId: 1,
yqMerchantId: 2,
method: "dj.api.smartcarlife.MerchantGoodsStockMonthReport.stockMove.log.page",
}, "post");
});
});