Files
medusa-store/integration-tests/api/__tests__/store/regions.js
Philip Korsholm 5b91a3503a feat(medusa): Add proper pagination (#4517)
* update method for listing regions

* add changeset

* fix unit tests

* listAndCount swaps

* add count calculation to list-returns

* swap integration test

* notes pagination

* pagination props for notifications

* listAndCount store regions

* fix nit

* fix note unit test

* update list-regions store unit test

* cleanup integration test

* rename introduced tests

---------

Co-authored-by: Oliver Windall Juhl <59018053+olivermrbl@users.noreply.github.com>
2023-07-14 16:14:51 +02:00

76 lines
1.7 KiB
JavaScript

const path = require("path")
const {
Region,
ReturnReason,
Order,
Customer,
ShippingProfile,
Product,
ProductVariant,
ShippingOption,
FulfillmentProvider,
LineItem,
Discount,
DiscountRule,
} = require("@medusajs/medusa")
const setupServer = require("../../../helpers/setup-server")
const { useApi } = require("../../../helpers/use-api")
const { initDb, useDb } = require("../../../helpers/use-db")
jest.setTimeout(30000)
describe("/store/carts", () => {
let medusaProcess
let dbConnection
beforeAll(async () => {
const cwd = path.resolve(path.join(__dirname, "..", ".."))
dbConnection = await initDb({ cwd })
medusaProcess = await setupServer({ cwd })
})
afterAll(async () => {
const db = useDb()
await db.shutdown()
medusaProcess.kill()
})
describe("GET /store/regions", () => {
beforeEach(async () => {
const manager = dbConnection.manager
await manager.insert(Region, {
id: "region",
name: "Test Region",
currency_code: "usd",
tax_rate: 0,
})
await manager.insert(Region, {
id: "region-1",
name: "Test Region 1",
currency_code: "usd",
tax_rate: 0,
})
})
afterEach(async () => {
const db = useDb()
await db.teardown()
})
it("should list the store regions with pagination", async () => {
const api = useApi()
const response = await api.get("/store/regions?limit=1&offset=1")
expect(response.status).toEqual(200)
expect(response.data.regions.length).toEqual(1)
expect(response.data.count).toEqual(2)
expect(response.data.offset).toEqual(1)
expect(response.data.limit).toEqual(1)
})
})
})