fix: add integration test

This commit is contained in:
Sebastian Rindom
2021-10-05 12:36:43 +02:00
parent 5a67d1e7fd
commit 38813ec66f
7 changed files with 172 additions and 79 deletions
@@ -1,5 +1,19 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`/admin/auth creates admin session correctly 1`] = `
Object {
"api_token": "test_token",
"created_at": Any<String>,
"deleted_at": null,
"email": "admin@medusa.js",
"first_name": null,
"id": "admin_user",
"last_name": null,
"metadata": null,
"updated_at": Any<String>,
}
`;
exports[`/admin/discounts creates admin session correctly 1`] = `
Object {
"api_token": "test_token",
@@ -13,4 +27,3 @@ Object {
"updated_at": Any<String>,
}
`;
@@ -1,5 +1,22 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`/admin/auth creates store session correctly 1`] = `
Object {
"billing_address_id": null,
"created_at": Any<String>,
"deleted_at": null,
"email": "test@testesen.dk",
"first_name": "test",
"has_account": true,
"id": Any<String>,
"last_name": "testesen",
"metadata": null,
"orders": Array [],
"phone": "12345678",
"updated_at": Any<String>,
}
`;
exports[`/admin/discounts creates store session correctly 1`] = `
Object {
"billing_address_id": null,
+39 -2
View File
@@ -135,8 +135,8 @@ describe("/store/carts", () => {
const api = useApi()
try {
await api.post("/store/carts/test-cart", {
discounts: [{ code: "CREATED" }],
const { data } = await api.post("/store/carts/test-cart", {
discounts: [{ code: "LIMIT_REACHED" }],
})
} catch (error) {
expect(error.response.status).toEqual(400)
@@ -648,4 +648,41 @@ describe("/store/carts", () => {
expect(response.status).toEqual(200)
})
})
describe("shipping address + region updates", () => {
beforeEach(async () => {
try {
await cartSeeder(dbConnection)
} catch (err) {
console.log(err)
throw err
}
})
afterEach(async () => {
await doAfterEach()
})
it("updates region only - single to multipe countries", async () => {
const api = useApi()
const { data, status } = await api
.post(`/store/carts/test-cart`, {
region_id: `test-region-multiple`,
})
.catch((err) => {
console.log(err)
throw err
})
expect(status).toEqual(200)
expect(data.cart.region_id).toEqual("test-region-multiple")
expect(data.cart.shipping_address).toMatchSnapshot({
id: expect.any(String),
country_code: null,
})
})
// it("updates cart.customer_id on cart retrieval if cart.customer_id differ from session customer", async () => {})
})
})