stockMove.spec.js 1.32 KB
import { buildStockMoveImportParams } from "./buildStockMoveImportParams";
import { mapLogPagePageResponse } from "./mapLogPageResponse";
import { mapProductManagerListUpgradeGoodsSimplePageResponse } from "./mapProductManagerListUpgradeGoodsSimpleResponse";

describe("stock move adapters", () => {
	it("passes the import file through without reading generated nested properties", () => {
		const file = new FormData();
		expect(buildStockMoveImportParams({ file })).toEqual({ file });
	});

	it("keeps product fields used by the remote selector", () => {
		const response = mapProductManagerListUpgradeGoodsSimplePageResponse({
			currentPage: 2,
			list: [{ id: 9, commodityCode: "UID-9", upgradeGoodsName: "产品A" }],
		});
		expect(response.pageNum).toBe(2);
		expect(response.list[0]).toMatchObject({
			id: 9,
			commodityCode: "UID-9",
			upgradeGoodsName: "产品A",
		});
	});

	it("keeps migration log fields used by the drawer", () => {
		const response = mapLogPagePageResponse({
			list: [{
				oldCommodityCode: "OLD",
				newCommodityCode: "NEW",
				moveStockNum: 3,
				createdBy: "张三",
				createdDate: "2026-08-05 12:30:00",
			}],
		});
		expect(response.list[0]).toEqual({
			oldCommodityCode: "OLD",
			newCommodityCode: "NEW",
			moveStockNum: 3,
			createdBy: "张三",
			createdDate: "2026-08-05 12:30:00",
		});
	});
});