adjusted product tests after removing sorting and public variant ranks
This commit is contained in:
1 parent
8e6bd6c97e
commit
976b57f944
1 file changed
+3
-31
@@ -16,14 +16,14 @@ describe("ProductService", () => {
|
|||||||
return {
|
return {
|
||||||
id: "test id with variants",
|
id: "test id with variants",
|
||||||
variants: [
|
variants: [
|
||||||
{ id: "test_321", title: "Green", variant_rank: 1 },
|
{ id: "test_321", title: "Green" },
|
||||||
{ id: "test_123", title: "Blue", variant_rank: 0 },
|
{ id: "test_123", title: "Blue" },
|
||||||
],
|
],
|
||||||
}
|
}
|
||||||
if (query.where.id === "test id one variant")
|
if (query.where.id === "test id one variant")
|
||||||
return {
|
return {
|
||||||
id: "test id one variant",
|
id: "test id one variant",
|
||||||
variants: [{ id: "test_123", title: "Blue", variant_rank: 0 }],
|
variants: [{ id: "test_123", title: "Blue" }],
|
||||||
}
|
}
|
||||||
return Promise.resolve({ id: IdMap.getId("ironman") })
|
return Promise.resolve({ id: IdMap.getId("ironman") })
|
||||||
},
|
},
|
||||||
@@ -38,30 +38,6 @@ describe("ProductService", () => {
|
|||||||
jest.clearAllMocks()
|
jest.clearAllMocks()
|
||||||
})
|
})
|
||||||
|
|
||||||
it("Orders variants according to rank when retrieving a product", async () => {
|
|
||||||
const result = await productService.retrieve("test id with variants", {
|
|
||||||
relations: ["Variants"],
|
|
||||||
})
|
|
||||||
|
|
||||||
expect(productRepo.findOneWithRelations).toHaveBeenCalledTimes(1)
|
|
||||||
expect(productRepo.findOneWithRelations).toHaveBeenCalledWith(
|
|
||||||
["Variants"],
|
|
||||||
{
|
|
||||||
where: { id: "test id with variants" },
|
|
||||||
}
|
|
||||||
)
|
|
||||||
|
|
||||||
const expected = {
|
|
||||||
id: "test id with variants",
|
|
||||||
variants: [
|
|
||||||
{ id: "test_123", title: "Blue", variant_rank: 0 },
|
|
||||||
{ id: "test_321", title: "Green", variant_rank: 1 },
|
|
||||||
],
|
|
||||||
}
|
|
||||||
|
|
||||||
expect(result).toEqual(expected)
|
|
||||||
})
|
|
||||||
|
|
||||||
it("successfully retrieves a product", async () => {
|
it("successfully retrieves a product", async () => {
|
||||||
const result = await productService.retrieve(IdMap.getId("ironman"))
|
const result = await productService.retrieve(IdMap.getId("ironman"))
|
||||||
|
|
||||||
@@ -162,12 +138,10 @@ describe("ProductService", () => {
|
|||||||
{
|
{
|
||||||
id: "test1",
|
id: "test1",
|
||||||
title: "green",
|
title: "green",
|
||||||
variant_rank: 0,
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: "test2",
|
id: "test2",
|
||||||
title: "blue",
|
title: "blue",
|
||||||
variant_rank: 1,
|
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
})
|
})
|
||||||
@@ -204,12 +178,10 @@ describe("ProductService", () => {
|
|||||||
{
|
{
|
||||||
id: "test1",
|
id: "test1",
|
||||||
title: "green",
|
title: "green",
|
||||||
variant_rank: 0,
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: "test2",
|
id: "test2",
|
||||||
title: "blue",
|
title: "blue",
|
||||||
variant_rank: 1,
|
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in new issue
Block a user