**What** Update the `MedusaService` class, factory and types to remove the concept of main modules. The idea being that all method will be explicitly named and suffixes to represent the object you are trying to manipulate. This pr also includes various fixes in different modules Co-authored-by: Stevche Radevski <4820812+sradevski@users.noreply.github.com> Co-authored-by: Oli Juhl <59018053+olivermrbl@users.noreply.github.com>
59 lines
1.6 KiB
TypeScript
59 lines
1.6 KiB
TypeScript
import { ModuleRegistrationName } from "@medusajs/modules-sdk"
|
|
import { IPromotionModuleService } from "@medusajs/types"
|
|
import { medusaIntegrationTestRunner } from "medusa-test-utils"
|
|
import { createAdminUser } from "../../../../helpers/create-admin-user"
|
|
|
|
jest.setTimeout(50000)
|
|
|
|
const env = { MEDUSA_FF_MEDUSA_V2: true }
|
|
const adminHeaders = {
|
|
headers: { "x-medusa-access-token": "test_token" },
|
|
}
|
|
|
|
medusaIntegrationTestRunner({
|
|
env,
|
|
testSuite: ({ dbConnection, getContainer, api }) => {
|
|
describe("DELETE /admin/promotions/:id", () => {
|
|
let appContainer
|
|
let promotionModuleService: IPromotionModuleService
|
|
|
|
beforeAll(async () => {
|
|
appContainer = getContainer()
|
|
promotionModuleService = appContainer.resolve(
|
|
ModuleRegistrationName.PROMOTION
|
|
)
|
|
})
|
|
|
|
beforeEach(async () => {
|
|
await createAdminUser(dbConnection, adminHeaders, appContainer)
|
|
})
|
|
|
|
it("should delete promotion successfully", async () => {
|
|
const createdPromotion = await promotionModuleService.createPromotions({
|
|
code: "TEST",
|
|
type: "standard",
|
|
application_method: {
|
|
type: "fixed",
|
|
target_type: "order",
|
|
value: "100",
|
|
currency_code: "USD",
|
|
},
|
|
})
|
|
|
|
const deleteRes = await api.delete(
|
|
`/admin/promotions/${createdPromotion.id}`,
|
|
adminHeaders
|
|
)
|
|
|
|
expect(deleteRes.status).toEqual(200)
|
|
|
|
const promotions = await promotionModuleService.listPromotions({
|
|
id: [createdPromotion.id],
|
|
})
|
|
|
|
expect(promotions.length).toEqual(0)
|
|
})
|
|
})
|
|
},
|
|
})
|