added expect-relations helper and used it to test get-cart

This commit is contained in:
--list
2021-06-17 16:55:05 +02:00
parent a2e6972c02
commit 8cd4e2e818
9 changed files with 97 additions and 4 deletions

View 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();
}
}

View File

@@ -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,
});
};