Skip to content

Commit

Permalink
add expected errors
Browse files Browse the repository at this point in the history
  • Loading branch information
olivermrbl committed Apr 6, 2024
1 parent 2b4b1d8 commit 7375cc6
Showing 1 changed file with 86 additions and 2 deletions.
88 changes: 86 additions & 2 deletions integration-tests/api/__tests__/admin/fulfillment-sets.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -153,17 +153,101 @@ medusaIntegrationTestRunner({
geo_zones: [
{
country_code: "dk",
region_name: "SJAELLAND",
type: "country",
},
{
country_code: "fr",
type: "province",
province_code: "fr-idf",
},
{
country_code: "it",
type: "region",
city: "some region",
province_code: "some-province",
},
{
country_code: "it",
type: "zip",
city: "some city",
province_code: "some-province",
postal_expression: {},
},
],
},
adminHeaders
)
.catch((err) => err.response)

const expectedErrors = [
{
code: "invalid_union",
unionErrors: [
{
issues: [
{
received: "region",
code: "invalid_literal",
expected: "country",
path: ["geo_zones", 2, "type"],
message: 'Invalid literal value, expected "country"',
},
],
name: "ZodError",
},
{
issues: [
{
received: "region",
code: "invalid_literal",
expected: "province",
path: ["geo_zones", 2, "type"],
message: 'Invalid literal value, expected "province"',
},
],
name: "ZodError",
},
{
issues: [
{
received: "region",
code: "invalid_literal",
expected: "city",
path: ["geo_zones", 2, "type"],
message: 'Invalid literal value, expected "city"',
},
],
name: "ZodError",
},
{
issues: [
{
received: "region",
code: "invalid_literal",
expected: "zip",
path: ["geo_zones", 2, "type"],
message: 'Invalid literal value, expected "zip"',
},
{
code: "invalid_type",
expected: "object",
received: "undefined",
path: ["geo_zones", 2, "postal_expression"],
message: "Required",
},
],
name: "ZodError",
},
],
path: ["geo_zones", 2],
message: "Invalid input",
},
]

expect(errorResponse.status).toEqual(400)
expect(errorResponse.data.message).toContain("Invalid request body: ")
expect(errorResponse.data.message).toContain(
`Invalid request body: ${JSON.stringify(expectedErrors)}`
)
})
})
},
Expand Down

0 comments on commit 7375cc6

Please sign in to comment.