fix(medusa,utils,types): inventory management nullable (#13703)
* fix(medusa,utils,types): inventory management nullable * fix unit * fix changeset
This commit is contained in:
1 parent
86c975258b
commit
c61f3150c1
5 files changed
+26
-13
No files matched your search
+11
-5
@@ -7,8 +7,8 @@ import {
|
||||
} from "@medusajs/framework/utils"
|
||||
import { MedusaRequest, MedusaStoreRequest } from "@medusajs/framework/http"
|
||||
import {
|
||||
wrapVariantsWithTotalInventoryQuantity,
|
||||
wrapVariantsWithInventoryQuantityForSalesChannel,
|
||||
wrapVariantsWithTotalInventoryQuantity,
|
||||
} from "../variant-inventory-quantity"
|
||||
|
||||
jest.mock("@medusajs/framework/utils", () => {
|
||||
@@ -79,7 +79,12 @@ describe("variant-inventory-quantity", () => {
|
||||
"variant-1": { availability: 10 },
|
||||
"variant-2": { availability: 5 },
|
||||
"variant-3": { availability: 20 },
|
||||
"variant-4": { availability: null },
|
||||
}
|
||||
const _variants = [
|
||||
...variants,
|
||||
{ id: "variant-4", manage_inventory: true },
|
||||
]
|
||||
|
||||
;(getTotalVariantAvailability as jest.Mock).mockResolvedValueOnce(
|
||||
mockAvailability
|
||||
@@ -87,12 +92,13 @@ describe("variant-inventory-quantity", () => {
|
||||
|
||||
await wrapVariantsWithTotalInventoryQuantity(
|
||||
req as MedusaRequest,
|
||||
variants
|
||||
_variants
|
||||
)
|
||||
|
||||
expect(variants[0].inventory_quantity).toBe(10)
|
||||
expect(variants[1].inventory_quantity).toBe(5)
|
||||
expect(variants[2].inventory_quantity).toBeUndefined()
|
||||
expect(_variants[0].inventory_quantity).toBe(10)
|
||||
expect(_variants[1].inventory_quantity).toBe(5)
|
||||
expect(_variants[2].inventory_quantity).toBeUndefined()
|
||||
expect(_variants[3].inventory_quantity).toBeNull()
|
||||
})
|
||||
})
|
||||
|
||||
|
||||
@@ -65,7 +65,7 @@ export const wrapVariantsWithInventoryQuantityForSalesChannel = async (
|
||||
|
||||
type VariantInput = {
|
||||
id: string
|
||||
inventory_quantity?: number
|
||||
inventory_quantity?: number | null
|
||||
manage_inventory?: boolean
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user