fix(utils): medusa internal service returned data should match typings (#12715)
FIXES SUP-1824 **What** The medusa internal service update should always return the data in the expected shape described by the interface. The medusa service should not have to handle the reshapre
This commit is contained in:
committed by
GitHub
parent
ea0b297b44
commit
ab634a14ba
@@ -285,6 +285,59 @@ moduleIntegrationTestRunner<Service>({
|
||||
)
|
||||
})
|
||||
|
||||
it("should update a product and its allowed relations using selector", async () => {
|
||||
const updateData = [
|
||||
{
|
||||
selector: {
|
||||
id: productOne.id,
|
||||
},
|
||||
data: {
|
||||
title: "update test 1",
|
||||
},
|
||||
},
|
||||
]
|
||||
|
||||
const products = await service.update(updateData)
|
||||
|
||||
expect(products.length).toEqual(1)
|
||||
|
||||
let result = await service.retrieve(productOne.id)
|
||||
let serialized = JSON.parse(JSON.stringify(result))
|
||||
|
||||
expect(serialized).toEqual(
|
||||
expect.objectContaining({
|
||||
id: productOne.id,
|
||||
title: "update test 1",
|
||||
})
|
||||
)
|
||||
})
|
||||
|
||||
it("should update a single product and its allowed relations", async () => {
|
||||
const updateData = {
|
||||
id: productOne.id,
|
||||
title: "update test 1",
|
||||
}
|
||||
|
||||
const product = await service.update(updateData)
|
||||
|
||||
expect(product).toEqual(
|
||||
expect.objectContaining({
|
||||
id: productOne.id,
|
||||
title: "update test 1",
|
||||
})
|
||||
)
|
||||
|
||||
let result = await service.retrieve(productOne.id)
|
||||
let serialized = JSON.parse(JSON.stringify(result))
|
||||
|
||||
expect(serialized).toEqual(
|
||||
expect.objectContaining({
|
||||
id: productOne.id,
|
||||
title: "update test 1",
|
||||
})
|
||||
)
|
||||
})
|
||||
|
||||
it("should throw an error when id is not present", async () => {
|
||||
let error
|
||||
const updateData = [
|
||||
|
||||
Reference in New Issue
Block a user