feat(pricing): pricing models are made soft deletable (#6732)
what: - pricing models are made soft deletable - adds missing timestamp attributes - removes unwanted relationships + cascade cleanup
This commit is contained in:
@@ -1,20 +0,0 @@
|
||||
export const defaultPriceSetMoneyAmountRulesData = [
|
||||
{
|
||||
id: "psmar-1",
|
||||
value: "EUR",
|
||||
price_set_money_amount: "price-set-money-amount-USD",
|
||||
rule_type: "rule-type-1",
|
||||
},
|
||||
{
|
||||
id: "psmar-2",
|
||||
value: "EU",
|
||||
price_set_money_amount: "price-set-money-amount-EUR",
|
||||
rule_type: "rule-type-2",
|
||||
},
|
||||
{
|
||||
id: "psmar-3",
|
||||
value: "CAD",
|
||||
price_set_money_amount: "price-set-money-amount-CAD",
|
||||
rule_type: "rule-type-2",
|
||||
},
|
||||
]
|
||||
@@ -1,22 +0,0 @@
|
||||
import { SqlEntityManager } from "@mikro-orm/postgresql"
|
||||
import { PriceSetMoneyAmountRules } from "@models"
|
||||
import { defaultPriceSetMoneyAmountRulesData } from "./data"
|
||||
|
||||
export * from "./data"
|
||||
|
||||
export async function createPriceSetMoneyAmountRules(
|
||||
manager: SqlEntityManager,
|
||||
psmarData: any[] = defaultPriceSetMoneyAmountRulesData
|
||||
): Promise<PriceSetMoneyAmountRules[]> {
|
||||
const priceSetMoneyAmountRules: PriceSetMoneyAmountRules[] = []
|
||||
|
||||
for (let data of psmarData) {
|
||||
const psmar = manager.create(PriceSetMoneyAmountRules, data)
|
||||
|
||||
priceSetMoneyAmountRules.push(psmar)
|
||||
}
|
||||
|
||||
await manager.persistAndFlush(priceSetMoneyAmountRules)
|
||||
|
||||
return priceSetMoneyAmountRules
|
||||
}
|
||||
@@ -7,10 +7,6 @@ import {
|
||||
createPriceSetMoneyAmounts,
|
||||
defaultPriceSetMoneyAmountsData,
|
||||
} from "./price-set-money-amount"
|
||||
import {
|
||||
createPriceSetMoneyAmountRules,
|
||||
defaultPriceSetMoneyAmountRulesData,
|
||||
} from "./price-set-money-amount-rules"
|
||||
import { createRuleTypes, defaultRuleTypesData } from "./rule-type"
|
||||
|
||||
jest.setTimeout(30000)
|
||||
@@ -22,7 +18,6 @@ export async function seedPriceData(
|
||||
priceSetsData = defaultPriceSetsData,
|
||||
priceRuleData = defaultPriceRuleData,
|
||||
priceSetMoneyAmountsData = defaultPriceSetMoneyAmountsData,
|
||||
priceSetMoneyAmountRulesData = defaultPriceSetMoneyAmountRulesData,
|
||||
ruleTypesData = defaultRuleTypesData,
|
||||
} = {}
|
||||
) {
|
||||
@@ -31,8 +26,4 @@ export async function seedPriceData(
|
||||
await createPriceSetMoneyAmounts(testManager, priceSetMoneyAmountsData)
|
||||
await createRuleTypes(testManager, ruleTypesData)
|
||||
await createPriceRules(testManager, priceRuleData)
|
||||
await createPriceSetMoneyAmountRules(
|
||||
testManager,
|
||||
priceSetMoneyAmountRulesData
|
||||
)
|
||||
}
|
||||
|
||||
-1
@@ -336,7 +336,6 @@ moduleIntegrationTestRunner({
|
||||
moneyAmountsData,
|
||||
priceSetsData,
|
||||
priceSetMoneyAmountsData,
|
||||
priceSetMoneyAmountRulesData: [],
|
||||
priceRuleData,
|
||||
ruleTypesData,
|
||||
})
|
||||
|
||||
+6
-10
@@ -1,13 +1,12 @@
|
||||
import { Modules } from "@medusajs/modules-sdk"
|
||||
import { IPricingModuleService } from "@medusajs/types"
|
||||
import { SqlEntityManager } from "@mikro-orm/postgresql"
|
||||
import { moduleIntegrationTestRunner, SuiteOptions } from "medusa-test-utils"
|
||||
import { createMoneyAmounts } from "../../../__fixtures__/money-amount"
|
||||
import { createPriceRules } from "../../../__fixtures__/price-rule"
|
||||
import { createPriceSets } from "../../../__fixtures__/price-set"
|
||||
import { createPriceSetMoneyAmounts } from "../../../__fixtures__/price-set-money-amount"
|
||||
import { createPriceSetMoneyAmountRules } from "../../../__fixtures__/price-set-money-amount-rules"
|
||||
import { createRuleTypes } from "../../../__fixtures__/rule-type"
|
||||
import { moduleIntegrationTestRunner, SuiteOptions } from "medusa-test-utils"
|
||||
|
||||
jest.setTimeout(30000)
|
||||
|
||||
@@ -245,18 +244,16 @@ moduleIntegrationTestRunner({
|
||||
describe("softDeleteMoneyAmounts", () => {
|
||||
const id = "money-amount-USD"
|
||||
|
||||
it("should softDelete priceSetMoneyAmount and PriceRule when soft-deleting money amount", async () => {
|
||||
it("should softDelete money amounts successfully", async () => {
|
||||
await createPriceSets(testManager)
|
||||
await createRuleTypes(testManager)
|
||||
await createPriceSetMoneyAmounts(testManager)
|
||||
await createPriceRules(testManager)
|
||||
await createPriceSetMoneyAmountRules(testManager)
|
||||
|
||||
await service.softDeleteMoneyAmounts([id])
|
||||
|
||||
const [moneyAmount] = await service.listMoneyAmounts(
|
||||
{
|
||||
id: [id],
|
||||
},
|
||||
{ id: [id] },
|
||||
{
|
||||
relations: [
|
||||
"price_set_money_amount",
|
||||
@@ -274,10 +271,10 @@ moduleIntegrationTestRunner({
|
||||
expect.objectContaining({
|
||||
deleted_at: deletedAt,
|
||||
price_set_money_amount: expect.objectContaining({
|
||||
deleted_at: deletedAt,
|
||||
deleted_at: null,
|
||||
price_rules: [
|
||||
expect.objectContaining({
|
||||
deleted_at: deletedAt,
|
||||
deleted_at: null,
|
||||
}),
|
||||
],
|
||||
}),
|
||||
@@ -294,7 +291,6 @@ moduleIntegrationTestRunner({
|
||||
await createRuleTypes(testManager)
|
||||
await createPriceSetMoneyAmounts(testManager)
|
||||
await createPriceRules(testManager)
|
||||
await createPriceSetMoneyAmountRules(testManager)
|
||||
await service.softDeleteMoneyAmounts([id])
|
||||
await service.restoreMoneyAmounts([id])
|
||||
|
||||
|
||||
+2
-5
@@ -1,15 +1,13 @@
|
||||
import { Modules } from "@medusajs/modules-sdk"
|
||||
import { CreatePriceRuleDTO, IPricingModuleService } from "@medusajs/types"
|
||||
import { SqlEntityManager } from "@mikro-orm/postgresql"
|
||||
|
||||
import { SuiteOptions, moduleIntegrationTestRunner } from "medusa-test-utils"
|
||||
import { PriceSetMoneyAmount } from "../../../../src"
|
||||
import { createMoneyAmounts } from "../../../__fixtures__/money-amount"
|
||||
import { createPriceRules } from "../../../__fixtures__/price-rule"
|
||||
import { createPriceSets } from "../../../__fixtures__/price-set"
|
||||
import { createPriceSetMoneyAmounts } from "../../../__fixtures__/price-set-money-amount"
|
||||
import { createPriceSetMoneyAmountRules } from "../../../__fixtures__/price-set-money-amount-rules"
|
||||
import { createRuleTypes } from "../../../__fixtures__/rule-type"
|
||||
import { Modules } from "@medusajs/modules-sdk"
|
||||
import { moduleIntegrationTestRunner, SuiteOptions } from "medusa-test-utils"
|
||||
|
||||
jest.setTimeout(30000)
|
||||
|
||||
@@ -28,7 +26,6 @@ moduleIntegrationTestRunner({
|
||||
await createPriceSets(testManager)
|
||||
await createRuleTypes(testManager)
|
||||
await createPriceSetMoneyAmounts(testManager)
|
||||
await createPriceSetMoneyAmountRules(testManager)
|
||||
await createPriceRules(testManager)
|
||||
})
|
||||
|
||||
|
||||
-278
@@ -1,278 +0,0 @@
|
||||
import { IPricingModuleService } from "@medusajs/types"
|
||||
import { SqlEntityManager } from "@mikro-orm/postgresql"
|
||||
import { createMoneyAmounts } from "../../../__fixtures__/money-amount"
|
||||
import { createPriceSets } from "../../../__fixtures__/price-set"
|
||||
import { createPriceSetMoneyAmounts } from "../../../__fixtures__/price-set-money-amount"
|
||||
import { createPriceSetMoneyAmountRules } from "../../../__fixtures__/price-set-money-amount-rules"
|
||||
import { createRuleTypes } from "../../../__fixtures__/rule-type"
|
||||
import { Modules } from "@medusajs/modules-sdk"
|
||||
import { moduleIntegrationTestRunner, SuiteOptions } from "medusa-test-utils"
|
||||
|
||||
jest.setTimeout(30000)
|
||||
|
||||
moduleIntegrationTestRunner({
|
||||
moduleName: Modules.PRICING,
|
||||
testSuite: ({
|
||||
MikroOrmWrapper,
|
||||
service,
|
||||
}: SuiteOptions<IPricingModuleService>) => {
|
||||
describe("PricingModule Service - PriceSetMoneyAmountRules", () => {
|
||||
beforeEach(async () => {
|
||||
const testManager = await MikroOrmWrapper.forkManager()
|
||||
|
||||
await createMoneyAmounts(testManager)
|
||||
await createPriceSets(testManager)
|
||||
await createRuleTypes(testManager)
|
||||
await createPriceSetMoneyAmounts(testManager)
|
||||
await createPriceSetMoneyAmountRules(testManager)
|
||||
})
|
||||
|
||||
describe("listPriceSetMoneyAmountRules", () => {
|
||||
it("should list psmar records", async () => {
|
||||
const priceSetMoneyAmountRulesResult =
|
||||
await service.listPriceSetMoneyAmountRules()
|
||||
|
||||
expect(priceSetMoneyAmountRulesResult).toEqual([
|
||||
expect.objectContaining({
|
||||
id: "psmar-1",
|
||||
}),
|
||||
expect.objectContaining({
|
||||
id: "psmar-2",
|
||||
}),
|
||||
expect.objectContaining({
|
||||
id: "psmar-3",
|
||||
}),
|
||||
])
|
||||
})
|
||||
|
||||
it("should list psmar record by id", async () => {
|
||||
const priceSetMoneyAmountRulesResult =
|
||||
await service.listPriceSetMoneyAmountRules({
|
||||
id: ["psmar-1"],
|
||||
})
|
||||
|
||||
expect(priceSetMoneyAmountRulesResult).toEqual([
|
||||
expect.objectContaining({
|
||||
id: "psmar-1",
|
||||
}),
|
||||
])
|
||||
})
|
||||
})
|
||||
|
||||
describe("listAndCount", () => {
|
||||
it("should return psmar records and count", async () => {
|
||||
const [priceSetMoneyAmountRulesResult, count] =
|
||||
await service.listAndCountPriceSetMoneyAmountRules()
|
||||
|
||||
expect(count).toEqual(3)
|
||||
expect(priceSetMoneyAmountRulesResult).toEqual([
|
||||
expect.objectContaining({
|
||||
id: "psmar-1",
|
||||
}),
|
||||
expect.objectContaining({
|
||||
id: "psmar-2",
|
||||
}),
|
||||
expect.objectContaining({
|
||||
id: "psmar-3",
|
||||
}),
|
||||
])
|
||||
})
|
||||
|
||||
it("should return psmar records and count when filtered", async () => {
|
||||
const [priceSetMoneyAmountRulesResult, count] =
|
||||
await service.listAndCountPriceSetMoneyAmountRules({
|
||||
id: ["psmar-1"],
|
||||
})
|
||||
|
||||
expect(count).toEqual(1)
|
||||
expect(priceSetMoneyAmountRulesResult).toEqual([
|
||||
expect.objectContaining({
|
||||
id: "psmar-1",
|
||||
}),
|
||||
])
|
||||
})
|
||||
|
||||
it("should return psmar and count when using skip and take", async () => {
|
||||
const [priceSetMoneyAmountRulesResult, count] =
|
||||
await service.listAndCountPriceSetMoneyAmountRules(
|
||||
{},
|
||||
{ skip: 1, take: 1 }
|
||||
)
|
||||
|
||||
expect(count).toEqual(3)
|
||||
expect(priceSetMoneyAmountRulesResult).toEqual([
|
||||
expect.objectContaining({
|
||||
id: "psmar-2",
|
||||
}),
|
||||
])
|
||||
})
|
||||
|
||||
it("should return requested fields", async () => {
|
||||
const [priceSetMoneyAmountRulesResult, count] =
|
||||
await service.listAndCountPriceSetMoneyAmountRules(
|
||||
{},
|
||||
{
|
||||
take: 1,
|
||||
select: ["value"],
|
||||
}
|
||||
)
|
||||
|
||||
const serialized = JSON.parse(
|
||||
JSON.stringify(priceSetMoneyAmountRulesResult)
|
||||
)
|
||||
|
||||
expect(count).toEqual(3)
|
||||
expect(serialized).toEqual([
|
||||
{
|
||||
id: "psmar-1",
|
||||
value: "EUR",
|
||||
},
|
||||
])
|
||||
})
|
||||
})
|
||||
|
||||
describe("retrievePriceSetMoneyAmountRules", () => {
|
||||
it("should return priceSetMoneyAmountRules for the given id", async () => {
|
||||
const priceSetMoneyAmountRules =
|
||||
await service.retrievePriceSetMoneyAmountRules("psmar-1")
|
||||
|
||||
expect(priceSetMoneyAmountRules).toEqual(
|
||||
expect.objectContaining({
|
||||
id: "psmar-1",
|
||||
})
|
||||
)
|
||||
})
|
||||
|
||||
it("should throw an error when priceSetMoneyAmountRules with id does not exist", async () => {
|
||||
let error
|
||||
|
||||
try {
|
||||
await service.retrievePriceSetMoneyAmountRules("does-not-exist")
|
||||
} catch (e) {
|
||||
error = e
|
||||
}
|
||||
|
||||
expect(error.message).toEqual(
|
||||
"PriceSetMoneyAmountRules with id: does-not-exist was not found"
|
||||
)
|
||||
})
|
||||
|
||||
it("should throw an error when an id is not provided", async () => {
|
||||
let error
|
||||
|
||||
try {
|
||||
await service.retrievePriceSetMoneyAmountRules(
|
||||
undefined as unknown as string
|
||||
)
|
||||
} catch (e) {
|
||||
error = e
|
||||
}
|
||||
|
||||
expect(error.message).toEqual(
|
||||
"priceSetMoneyAmountRules - id must be defined"
|
||||
)
|
||||
})
|
||||
|
||||
it("should return priceSetMoneyAmountRules based on config select param", async () => {
|
||||
const priceSetMoneyAmountRulesResult =
|
||||
await service.retrievePriceSetMoneyAmountRules("psmar-1", {
|
||||
select: ["value"],
|
||||
})
|
||||
|
||||
const serialized = JSON.parse(
|
||||
JSON.stringify(priceSetMoneyAmountRulesResult)
|
||||
)
|
||||
|
||||
expect(serialized).toEqual({
|
||||
value: "EUR",
|
||||
id: "psmar-1",
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
describe("deletePriceSetMoneyAmountRules", () => {
|
||||
const id = "psmar-1"
|
||||
|
||||
it("should delete the priceSetMoneyAmountRuless given an id successfully", async () => {
|
||||
await service.deletePriceSetMoneyAmountRules([id])
|
||||
|
||||
const currencies = await service.listPriceSetMoneyAmountRules({
|
||||
id: [id],
|
||||
})
|
||||
|
||||
expect(currencies).toHaveLength(0)
|
||||
})
|
||||
})
|
||||
|
||||
describe("updatePriceSetMoneyAmountRules", () => {
|
||||
const id = "psmar-1"
|
||||
|
||||
it("should update the value of the priceSetMoneyAmountRules successfully", async () => {
|
||||
await service.updatePriceSetMoneyAmountRules([
|
||||
{
|
||||
id,
|
||||
value: "New value",
|
||||
},
|
||||
])
|
||||
|
||||
const psmar = await service.retrievePriceSetMoneyAmountRules(id)
|
||||
|
||||
expect(psmar.value).toEqual("New value")
|
||||
})
|
||||
|
||||
it("should throw an error when a id does not exist", async () => {
|
||||
let error
|
||||
|
||||
try {
|
||||
await service.updatePriceSetMoneyAmountRules([
|
||||
{
|
||||
id: "does-not-exist",
|
||||
value: "random value",
|
||||
},
|
||||
])
|
||||
} catch (e) {
|
||||
error = e
|
||||
}
|
||||
|
||||
expect(error.message).toEqual(
|
||||
'PriceSetMoneyAmountRules with id "does-not-exist" not found'
|
||||
)
|
||||
})
|
||||
})
|
||||
|
||||
describe("createPriceSetMoneyAmountRules", () => {
|
||||
it("should create a priceSetMoneyAmountRules successfully", async () => {
|
||||
await service.createPriceSetMoneyAmountRules([
|
||||
{
|
||||
price_set_money_amount: "price-set-money-amount-EUR",
|
||||
rule_type: "rule-type-2",
|
||||
value: "New priceSetMoneyAmountRule",
|
||||
},
|
||||
])
|
||||
|
||||
const [created] = await service.listPriceSetMoneyAmountRules(
|
||||
{
|
||||
value: ["New priceSetMoneyAmountRule"],
|
||||
},
|
||||
{
|
||||
relations: ["price_set_money_amount", "rule_type"],
|
||||
}
|
||||
)
|
||||
|
||||
expect(created).toEqual(
|
||||
expect.objectContaining({
|
||||
id: expect.any(String),
|
||||
value: "New priceSetMoneyAmountRule",
|
||||
price_set_money_amount: expect.objectContaining({
|
||||
id: "price-set-money-amount-EUR",
|
||||
}),
|
||||
rule_type: expect.objectContaining({
|
||||
id: "rule-type-2",
|
||||
}),
|
||||
})
|
||||
)
|
||||
})
|
||||
})
|
||||
})
|
||||
},
|
||||
})
|
||||
+73
-36
@@ -84,8 +84,12 @@ moduleIntegrationTestRunner({
|
||||
id: ["price-set-1"],
|
||||
},
|
||||
{
|
||||
select: ["id", "money_amounts.id", "money_amounts.amount"],
|
||||
relations: ["money_amounts"],
|
||||
select: [
|
||||
"id",
|
||||
"price_set_money_amounts.money_amount.id",
|
||||
"price_set_money_amounts.money_amount.amount",
|
||||
],
|
||||
relations: ["price_set_money_amounts.money_amount"],
|
||||
}
|
||||
)
|
||||
|
||||
@@ -94,10 +98,12 @@ moduleIntegrationTestRunner({
|
||||
expect(serialized).toEqual([
|
||||
{
|
||||
id: "price-set-1",
|
||||
money_amounts: [
|
||||
price_set_money_amounts: [
|
||||
expect.objectContaining({
|
||||
id: "money-amount-USD",
|
||||
amount: 500,
|
||||
money_amount: expect.objectContaining({
|
||||
id: "money-amount-USD",
|
||||
amount: 500,
|
||||
}),
|
||||
}),
|
||||
],
|
||||
},
|
||||
@@ -143,7 +149,7 @@ moduleIntegrationTestRunner({
|
||||
},
|
||||
{
|
||||
select: ["id", "min_quantity", "money_amounts.id"],
|
||||
relations: ["money_amounts"],
|
||||
relations: ["price_set_money_amounts.money_amount"],
|
||||
}
|
||||
)
|
||||
|
||||
@@ -153,8 +159,12 @@ moduleIntegrationTestRunner({
|
||||
expect(serialized).toEqual([
|
||||
{
|
||||
id: "price-set-1",
|
||||
money_amounts: [
|
||||
expect.objectContaining({ id: "money-amount-USD" }),
|
||||
price_set_money_amounts: [
|
||||
expect.objectContaining({
|
||||
money_amount: expect.objectContaining({
|
||||
id: "money-amount-USD",
|
||||
}),
|
||||
}),
|
||||
],
|
||||
},
|
||||
])
|
||||
@@ -368,10 +378,12 @@ moduleIntegrationTestRunner({
|
||||
rule_attribute: "region_id",
|
||||
}),
|
||||
],
|
||||
money_amounts: [
|
||||
price_set_money_amounts: [
|
||||
expect.objectContaining({
|
||||
amount: 100,
|
||||
currency_code: "USD",
|
||||
money_amount: expect.objectContaining({
|
||||
amount: 100,
|
||||
currency_code: "USD",
|
||||
}),
|
||||
}),
|
||||
],
|
||||
})
|
||||
@@ -405,14 +417,18 @@ moduleIntegrationTestRunner({
|
||||
rule_attribute: "region_id",
|
||||
}),
|
||||
],
|
||||
money_amounts: expect.arrayContaining([
|
||||
price_set_money_amounts: expect.arrayContaining([
|
||||
expect.objectContaining({
|
||||
amount: 100,
|
||||
currency_code: "USD",
|
||||
money_amount: expect.objectContaining({
|
||||
amount: 100,
|
||||
currency_code: "USD",
|
||||
}),
|
||||
}),
|
||||
expect.objectContaining({
|
||||
amount: 150,
|
||||
currency_code: "USD",
|
||||
money_amount: expect.objectContaining({
|
||||
amount: 150,
|
||||
currency_code: "USD",
|
||||
}),
|
||||
}),
|
||||
]),
|
||||
})
|
||||
@@ -442,10 +458,12 @@ moduleIntegrationTestRunner({
|
||||
rule_attribute: "region_id",
|
||||
}),
|
||||
],
|
||||
money_amounts: [
|
||||
price_set_money_amounts: [
|
||||
expect.objectContaining({
|
||||
amount: 100,
|
||||
currency_code: "USD",
|
||||
money_amount: expect.objectContaining({
|
||||
amount: 100,
|
||||
currency_code: "USD",
|
||||
}),
|
||||
}),
|
||||
],
|
||||
price_rules: [
|
||||
@@ -520,7 +538,11 @@ moduleIntegrationTestRunner({
|
||||
id: [createdPriceSet[0].id],
|
||||
},
|
||||
{
|
||||
relations: ["rule_types", "money_amounts", "price_rules"],
|
||||
relations: [
|
||||
"rule_types",
|
||||
"price_set_money_amounts.money_amount",
|
||||
"price_rules",
|
||||
],
|
||||
}
|
||||
)
|
||||
|
||||
@@ -536,10 +558,12 @@ moduleIntegrationTestRunner({
|
||||
}),
|
||||
},
|
||||
],
|
||||
money_amounts: [
|
||||
price_set_money_amounts: [
|
||||
expect.objectContaining({
|
||||
amount: 500,
|
||||
currency_code: "EUR",
|
||||
money_amount: expect.objectContaining({
|
||||
amount: 500,
|
||||
currency_code: "EUR",
|
||||
}),
|
||||
}),
|
||||
],
|
||||
rule_types: [
|
||||
@@ -563,15 +587,22 @@ moduleIntegrationTestRunner({
|
||||
id: [createdPriceSet[0].id],
|
||||
},
|
||||
{
|
||||
relations: ["rule_types", "money_amounts", "price_rules"],
|
||||
relations: [
|
||||
"rule_types",
|
||||
"price_set_money_amounts",
|
||||
"price_rules",
|
||||
],
|
||||
}
|
||||
)
|
||||
expect(priceSet).toEqual([
|
||||
{
|
||||
id: expect.any(String),
|
||||
price_rules: [],
|
||||
money_amounts: [],
|
||||
price_set_money_amounts: [],
|
||||
rule_types: [],
|
||||
created_at: expect.any(Date),
|
||||
updated_at: expect.any(Date),
|
||||
deleted_at: null,
|
||||
},
|
||||
])
|
||||
})
|
||||
@@ -594,16 +625,18 @@ moduleIntegrationTestRunner({
|
||||
|
||||
const [priceSet] = await service.list(
|
||||
{ id: ["price-set-1"] },
|
||||
{ relations: ["money_amounts"] }
|
||||
{ relations: ["price_set_money_amounts.money_amount"] }
|
||||
)
|
||||
|
||||
expect(priceSet).toEqual(
|
||||
expect.objectContaining({
|
||||
id: "price-set-1",
|
||||
money_amounts: expect.arrayContaining([
|
||||
price_set_money_amounts: expect.arrayContaining([
|
||||
expect.objectContaining({
|
||||
amount: 100,
|
||||
currency_code: "USD",
|
||||
money_amount: expect.objectContaining({
|
||||
amount: 100,
|
||||
currency_code: "USD",
|
||||
}),
|
||||
}),
|
||||
]),
|
||||
})
|
||||
@@ -636,25 +669,29 @@ moduleIntegrationTestRunner({
|
||||
|
||||
const priceSets = await service.list(
|
||||
{ id: ["price-set-1", "price-set-2"] },
|
||||
{ relations: ["money_amounts"] }
|
||||
{ relations: ["price_set_money_amounts.money_amount"] }
|
||||
)
|
||||
|
||||
expect(priceSets).toEqual([
|
||||
expect.objectContaining({
|
||||
id: "price-set-1",
|
||||
money_amounts: expect.arrayContaining([
|
||||
price_set_money_amounts: expect.arrayContaining([
|
||||
expect.objectContaining({
|
||||
amount: 100,
|
||||
currency_code: "USD",
|
||||
money_amount: expect.objectContaining({
|
||||
amount: 100,
|
||||
currency_code: "USD",
|
||||
}),
|
||||
}),
|
||||
]),
|
||||
}),
|
||||
expect.objectContaining({
|
||||
id: "price-set-2",
|
||||
money_amounts: expect.arrayContaining([
|
||||
price_set_money_amounts: expect.arrayContaining([
|
||||
expect.objectContaining({
|
||||
amount: 150,
|
||||
currency_code: "EUR",
|
||||
money_amount: expect.objectContaining({
|
||||
amount: 150,
|
||||
currency_code: "EUR",
|
||||
}),
|
||||
}),
|
||||
]),
|
||||
}),
|
||||
|
||||
Reference in New Issue
Block a user