Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commita4769d8

Browse files
committed
refactor: clean up eventsource mock
1 parent27be8c2 commita4769d8

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

‎site/src/pages/WorkspacePage/WorkspacePage.test.tsx

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import{fireEvent,screen,waitFor}from"@testing-library/react"
22
importuserEventfrom"@testing-library/user-event"
3-
importEventSourcefrom"eventsourcemock"
3+
importEventSourceMockfrom"eventsourcemock"
44
importi18nextfrom"i18next"
55
import{rest}from"msw"
66
import*asapifrom"../../api/api"
@@ -70,13 +70,20 @@ const testStatus = async (ws: Workspace, label: string) => {
7070
expect(status).toHaveTextContent(label)
7171
}
7272

73+
letoriginalEventSource:typeofwindow.EventSource
74+
75+
beforeAll(()=>{
76+
originalEventSource=window.EventSource
77+
// mocking out EventSource for SSE
78+
window.EventSource=EventSourceMock
79+
})
80+
7381
beforeEach(()=>{
7482
jest.resetAllMocks()
83+
})
7584

76-
// mocking out EventSource for SSE
77-
Object.defineProperty(window,"EventSource",{
78-
value:EventSource,
79-
})
85+
afterAll(()=>{
86+
window.EventSource=originalEventSource
8087
})
8188

8289
describe("WorkspacePage",()=>{

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp