Skip to content

Commit

Permalink
rm timeout mock
Browse files Browse the repository at this point in the history
  • Loading branch information
carlos-r-l-rodrigues committed Jan 10, 2025
1 parent 5ecdcc6 commit a20977b
Showing 1 changed file with 3 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ import {
Modules,
TransactionHandlerType,
} from "@medusajs/framework/utils"
import { moduleIntegrationTestRunner } from "@medusajs/test-utils"
import { WorkflowsModuleService } from "@services"
import { asFunction } from "awilix"
import { moduleIntegrationTestRunner } from "@medusajs/test-utils"
import { setTimeout as setTimeoutPromise } from "timers/promises"
import "../__fixtures__"
import {
Expand Down Expand Up @@ -332,27 +332,21 @@ moduleIntegrationTestRunner<IWorkflowEngineService>({

describe("Scheduled workflows", () => {
beforeEach(() => {
jest.clearAllMocks()
})

beforeAll(() => {
jest.useFakeTimers()
jest.spyOn(global, "setTimeout")
jest.clearAllMocks()
})

afterAll(() => {
afterEach(() => {
jest.useRealTimers()
})

it("should execute a scheduled workflow", async () => {
const spy = createScheduled("standard")

await jest.runOnlyPendingTimersAsync()
expect(setTimeout).toHaveBeenCalledTimes(2)
expect(spy).toHaveBeenCalledTimes(1)

await jest.runOnlyPendingTimersAsync()
expect(setTimeout).toHaveBeenCalledTimes(3)
expect(spy).toHaveBeenCalledTimes(2)
})

Expand Down

0 comments on commit a20977b

Please sign in to comment.