Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(browser): fix browser mock factory event race condition #6530

Merged
merged 3 commits into from
Sep 25, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
test: add test
  • Loading branch information
hi-ogawa committed Sep 19, 2024
commit 0f01415c19f4c2b3eb2045dbb78353e8be3c2496
13 changes: 13 additions & 0 deletions test/browser/fixtures/mocking/mocked-factory.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { expect, test, vi } from 'vitest'
import { calculator, mocked } from './src/mocks_factory'
import factoryMany from './src/mocks_factory_many'

vi.mock(import('./src/mocks_factory'), () => {
return {
Expand All @@ -8,7 +9,19 @@ vi.mock(import('./src/mocks_factory'), () => {
}
})

vi.mock(import('./src/mocks_factory_many_dep1'), () => ({
dep1: "dep1-mocked"
}))
vi.mock(import('./src/mocks_factory_many_dep2'), () => ({
dep2: "dep2-mocked"
}))

test('adds', () => {
expect(mocked).toBe(true)
expect(calculator('plus', 1, 2)).toBe(1166)

expect(factoryMany).toEqual({
"dep1": "dep1-mocked",
"dep2": "dep2-mocked",
})
})
4 changes: 4 additions & 0 deletions test/browser/fixtures/mocking/src/mocks_factory_many.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import { dep1 } from "./mocks_factory_many_dep1";
import { dep2 } from "./mocks_factory_many_dep2";

export default { dep1, dep2 }
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export const dep1: string = "dep1"
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export const dep2: string = "dep2"
Loading