fix(medusa): Support q search and order in list regions (#6202)
This commit is contained in:
@@ -138,6 +138,20 @@ describe("/admin/regions", () => {
|
||||
tax_rate: 0,
|
||||
updated_at: new Date("10/10/2000"),
|
||||
})
|
||||
await manager.insert(Region, {
|
||||
id: "us-region",
|
||||
name: "United States",
|
||||
currency_code: "usd",
|
||||
tax_rate: 0,
|
||||
updated_at: new Date("10/10/2000"),
|
||||
})
|
||||
await manager.insert(Region, {
|
||||
id: "uk-region",
|
||||
name: "United Kingdom",
|
||||
currency_code: "gbp",
|
||||
tax_rate: 0,
|
||||
updated_at: new Date("10/10/2000"),
|
||||
})
|
||||
})
|
||||
|
||||
afterEach(async () => {
|
||||
@@ -162,6 +176,28 @@ describe("/admin/regions", () => {
|
||||
)
|
||||
})
|
||||
|
||||
it("should list the regions with q and order params", async () => {
|
||||
const api = useApi()
|
||||
|
||||
const response = await api.get(
|
||||
"/admin/regions?q=united&order=currency_code",
|
||||
adminReqConfig
|
||||
)
|
||||
|
||||
expect(response.status).toEqual(200)
|
||||
|
||||
expect(response.data.regions).toEqual([
|
||||
expect.objectContaining({
|
||||
name: "United Kingdom",
|
||||
currency_code: "gbp",
|
||||
}),
|
||||
expect.objectContaining({
|
||||
name: "United States",
|
||||
currency_code: "usd",
|
||||
}),
|
||||
])
|
||||
})
|
||||
|
||||
it("should only return non-deleted regions", async () => {
|
||||
const api = useApi()
|
||||
|
||||
@@ -171,7 +207,7 @@ describe("/admin/regions", () => {
|
||||
console.log(err)
|
||||
})
|
||||
|
||||
expect(response.data.regions).toHaveLength(3)
|
||||
expect(response.data.regions).toHaveLength(5)
|
||||
expect(response.data.regions).toEqual(
|
||||
expect.arrayContaining([
|
||||
expect.objectContaining({
|
||||
@@ -194,7 +230,7 @@ describe("/admin/regions", () => {
|
||||
const response = await api.get(`/admin/regions?limit=2`, adminReqConfig)
|
||||
|
||||
expect(response.data.regions).toHaveLength(2)
|
||||
expect(response.data.count).toEqual(3)
|
||||
expect(response.data.count).toEqual(5)
|
||||
expect(response.status).toEqual(200)
|
||||
})
|
||||
|
||||
|
||||
Reference in New Issue
Block a user