41 lines
979 B
JavaScript
41 lines
979 B
JavaScript
import { expect, test } from "vitest";
|
|
import { applyGiftPriceDefaults, applyGiftResourceSelection } from "./useResourcePages.js";
|
|
|
|
test("fills gift name and id from selected gift resource", () => {
|
|
const form = {
|
|
coinPrice: "10",
|
|
giftId: "",
|
|
name: "",
|
|
resourceId: "",
|
|
};
|
|
|
|
const nextForm = applyGiftResourceSelection(form, {
|
|
coinPrice: 10,
|
|
name: "Rose",
|
|
priceType: "coin",
|
|
resourceCode: "gift_rose",
|
|
resourceId: 11,
|
|
});
|
|
|
|
expect(nextForm).toMatchObject({
|
|
coinPrice: "10",
|
|
giftId: "11",
|
|
name: "Rose",
|
|
resourceId: "11",
|
|
});
|
|
});
|
|
|
|
test("fills gift price without gift points", () => {
|
|
const form = {
|
|
coinPrice: "",
|
|
name: "Rose",
|
|
};
|
|
|
|
expect(applyGiftPriceDefaults(form, "100")).toMatchObject({
|
|
coinPrice: "100",
|
|
});
|
|
expect(applyGiftPriceDefaults(form, "101")).toMatchObject({
|
|
coinPrice: "101",
|
|
});
|
|
});
|