added expect-relations helper and used it to test get-cart
This commit is contained in:
20
integration-tests/api/helpers/expect-relations.js
Normal file
20
integration-tests/api/helpers/expect-relations.js
Normal file
@@ -0,0 +1,20 @@
|
||||
const { expect } = require("@jest/globals")
|
||||
|
||||
export function expectRelations(expected, actual){
|
||||
expected.forEach(a => expectRelations_(a, actual))
|
||||
}
|
||||
|
||||
function expectRelations_(expected, actual){
|
||||
const items = expected.split(".");
|
||||
let data_ = actual;
|
||||
|
||||
for(const i in items){
|
||||
data_ = data_[items[i]];
|
||||
|
||||
if(data_ instanceof Array && data_.length > 0) {
|
||||
data_ = data_[0];
|
||||
}
|
||||
|
||||
expect(data_).toBeDefined();
|
||||
}
|
||||
}
|
||||
@@ -6,6 +6,7 @@ const {
|
||||
Product,
|
||||
ShippingProfile,
|
||||
ProductVariant,
|
||||
MoneyAmount,
|
||||
Image,
|
||||
} = require("@medusajs/medusa");
|
||||
|
||||
@@ -74,7 +75,14 @@ module.exports = async (connection, data = {}) => {
|
||||
inventory_quantity: 10,
|
||||
title: "Test variant",
|
||||
product_id: "test-product",
|
||||
prices: [{ id: "test-price", currency_code: "usd", amount: 100 }],
|
||||
prices: [],
|
||||
options: [{ id: "test-variant-option", value: "Default variant" }],
|
||||
});
|
||||
|
||||
await manager.insert(MoneyAmount, {
|
||||
variant_id: "test-variant",
|
||||
id: "test-price",
|
||||
currency_code: "usd",
|
||||
amount: 100,
|
||||
});
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user