fix: Remove undefined from events in update (#10170)

This commit is contained in:
Oli Juhl
2024-11-20 09:43:51 +01:00
committed by GitHub
parent 7390c14c20
commit 8091c5f5bc
2 changed files with 34 additions and 4 deletions

View File

@@ -1,7 +1,7 @@
import { IRegionModuleService } from "@medusajs/framework/types"
import { Module, Modules } from "@medusajs/framework/utils"
import { RegionModuleService } from "@services"
import { moduleIntegrationTestRunner } from "@medusajs/test-utils"
import { RegionModuleService } from "@services"
jest.setTimeout(30000)
@@ -403,6 +403,32 @@ moduleIntegrationTestRunner<IRegionModuleService>({
expect(resp.countries).toHaveLength(2)
})
it("should delete a region without countries", async () => {
const createdRegion = await service.createRegions({
name: "North America",
currency_code: "USD",
countries: [],
})
await service.softDeleteRegions([createdRegion.id])
const [deletedRegion] = await service.listRegions(
{ id: createdRegion.id },
{ withDeleted: true }
)
expect(deletedRegion).toEqual({
id: createdRegion.id,
name: createdRegion.name,
currency_code: createdRegion.currency_code,
metadata: null,
automatic_taxes: createdRegion.automatic_taxes,
created_at: expect.any(Date),
updated_at: expect.any(Date),
deleted_at: expect.any(Date),
})
})
it("should unset the region ID on the country when soft deleting a region", async () => {
const createdRegion = await service.createRegions({
name: "North America",