Skip to content

Commit

Permalink
build(deps): update jest-websocket-mock to v2.5.0
Browse files Browse the repository at this point in the history
  • Loading branch information
theborakompanioni committed Nov 26, 2023
1 parent fa58f94 commit cc0a3cf
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 285 deletions.
292 changes: 17 additions & 275 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"http-proxy-middleware": "^2.0.6",
"husky": "^8.0.1",
"jest-watch-typeahead": "^2.2.2",
"jest-websocket-mock": "^2.4.0",
"jest-websocket-mock": "^2.5.0",
"lint-staged": "^13.0.3",
"prettier": "^3.0.3",
"react-scripts": "^5.0.1",
Expand Down
3 changes: 1 addition & 2 deletions src/components/App.test.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { render, screen } from '../testUtils'
import { act } from 'react-dom/test-utils'
import { render, screen, act } from '../testUtils'
import user from '@testing-library/user-event'
import * as apiMock from '../libs/JmWalletApi'

Expand Down
4 changes: 2 additions & 2 deletions src/context/WebsocketContext.jsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { createContext, useEffect, useState, useContext } from 'react'

import { useCurrentWallet } from './WalletContext'
import { noop } from '../utils'
import { isDevMode } from '../constants/debugFeatures'
Expand Down Expand Up @@ -30,7 +29,8 @@ const logToDebugConsoleInDevMode = isDevMode() ? console.debug : noop
const createWebSocket = () => {
const { protocol, host } = window.location
const scheme = protocol === 'https:' ? 'wss' : 'ws'
const websocket = new WebSocket(`${scheme}://${host}${WEBSOCKET_ENDPOINT_PATH}`)
const url = `${scheme}://${host}${WEBSOCKET_ENDPOINT_PATH}`
const websocket = new WebSocket(url)

websocket.onerror = (error) => {
console.error('[Websocket] error', error)
Expand Down
6 changes: 1 addition & 5 deletions src/setupTests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,9 @@ global.__DEV__.addToAppSettings = () => {
;(function setupWebsocketServerMock() {
global.__DEV__.JM_WEBSOCKET_SERVER_MOCK = new WebSocketServer('ws://localhost/jmws', { jsonProtocol: true })

afterEach(() => {
// gracefully close all open connections and reset the environment between test runs
WebSocketServer.clean()
})

afterAll(() => {
global.__DEV__.JM_WEBSOCKET_SERVER_MOCK.close()
WebSocketServer.clean()
})
})()

Expand Down

0 comments on commit cc0a3cf

Please sign in to comment.