Skip to content

Commit

Permalink
fix some issues
Browse files Browse the repository at this point in the history
  • Loading branch information
mvadari committed Dec 21, 2024
1 parent 51e0c93 commit ce5fe9b
Show file tree
Hide file tree
Showing 10 changed files with 17,319 additions and 22,968 deletions.
40,240 changes: 17,296 additions & 22,944 deletions package-lock.json

Large diffs are not rendered by default.

8 changes: 3 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
"@babel/preset-react": "^7.24.7",
"@types/create-hash": "^1.2.6",
"@types/enzyme": "^3.10.12",
"@types/jest": "^26.0.24",
"@types/jest": "^29.5.14",
"@types/lodash": "^4.17.6",
"@types/node": "^18.19.33",
"@types/react": "^17.0.39",
Expand All @@ -84,7 +84,8 @@
"eslint-plugin-prettier": "^5.1.3",
"eslint-plugin-react": "^7.34.2",
"eslint-plugin-react-hooks": "^4.6.2",
"jest-enzyme": "^7.1.0",
"jest-environment-jsdom": "29.7.0",
"jest-enzyme": "^7.1.2",
"jest-websocket-mock": "^2.5.0",
"lint-staged": "^15.2.10",
"mock-socket": "^9.1.5",
Expand All @@ -108,9 +109,6 @@
"typescript": "^4.9.5",
"xrpl": "^3.1.0"
},
"resolutions": {
"jest-environment-jsdom": "29.3.1"
},
"lint-staged": {
"src/**/*.{js,jsx,json,scss}": [
"prettier --write",
Expand Down
6 changes: 2 additions & 4 deletions src/containers/Amendment/test/amendment-summary.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ describe('Amendments Page container', () => {
wrapper.unmount()
})

it('renders all parts for a voting amendment', async (done) => {
it('renders all parts for a voting amendment', async () => {
moxios.stubRequest(
`${process.env.VITE_DATA_URL}/amendment/vote/main/${MOCK_IDENTIFIER}`,
{
Expand Down Expand Up @@ -200,10 +200,9 @@ describe('Amendments Page container', () => {
).toBe(4)

wrapper.unmount()
done()
})

it('renders 404 page on no match', async (done) => {
it('renders 404 page on no match', async () => {
moxios.stubRequest(
`${process.env.VITE_DATA_URL}/amendment/vote/main/${MOCK_IDENTIFIER}`,
{
Expand All @@ -225,6 +224,5 @@ describe('Amendments Page container', () => {

expect(wrapper.find('.no-match').length).toBe(1)
wrapper.unmount()
done()
})
})
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,11 @@ describe('NetworkPicker component', () => {
const createWrapper = (localNetworks?: string[]) => {
let Picker

jest.unmock('../NetworkPicker')
// Needed to test different env variable values.
jest.isolateModules(() => {
;({ NetworkPicker: Picker } = jest.requireActual('../NetworkPicker'))
const module = jest.requireActual('../NetworkPicker')
Picker = module.NetworkPicker
})

localStorage.removeItem(CUSTOM_NETWORKS_STORAGE_KEY)
Expand Down
14 changes: 7 additions & 7 deletions src/containers/Token/DEXPairs/test/hooks.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,23 +75,23 @@ describe('Testing hooks', () => {
})

it('renders all pairs', (done) => {
setImmediate(() => {
setTimeout(() => {
wrapper.update()
const allPairs = wrapper.find('.pair')
// 3 from the mockTopEndpoint and 3 from hardcoded pairs
expect(allPairs.length).toEqual(6)
done()
})
}, 0)
})
it('renders all PairStats components', (done) => {
setImmediate(() => {
setTimeout(() => {
wrapper.update()
const allLows = wrapper.find('.low')
const allHighs = wrapper.find('.high')
expect(allLows.length).toEqual(12)
expect(allHighs.length).toEqual(12)
done()
})
}, 0)
})
})

Expand All @@ -106,13 +106,13 @@ describe('Testing hooks', () => {
})

it('renders on top tokens failure', (done) => {
// setImmediate will execute the callback immediately after all queued promise callbacks are executed
setImmediate(() => {
// setTimeout will execute the callback immediately after all queued promise callbacks are executed
setTimeout(() => {
wrapper.update()
const noTokensNode = wrapper.find('.no-pairs-message')
expect(noTokensNode.length).toEqual(1)
done()
})
}, 0)
})
})
})
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { mount } from 'enzyme'
import { DropdownItem } from '../DropdownItem'
import createSpy = jasmine.createSpy

describe('DropdownItem', () => {
describe(`prop: className`, () => {
Expand All @@ -14,7 +13,7 @@ describe('DropdownItem', () => {

describe('prop: handler', () => {
let wrapper
const handler = createSpy('handler')
const handler = jest.fn()

beforeEach(() => {
wrapper = mount(<DropdownItem handler={handler}>Hello</DropdownItem>)
Expand Down
2 changes: 1 addition & 1 deletion src/containers/test/utils.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { testQueryClient } from './QueryClient'
import { AnalyticsSetPath } from '../shared/analytics'

export function flushPromises() {
return new Promise((resolve) => setImmediate(resolve))
return new Promise((resolve) => setTimeout(resolve, 0))
}

// @ts-ignore
Expand Down
2 changes: 1 addition & 1 deletion testUtils/cssTransform.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module.exports = {
process() {
return 'module.exports = {};'
return { code: 'module.exports = {};' }
},
getCacheKey() {
// The output is always the same.
Expand Down
2 changes: 1 addition & 1 deletion testUtils/imageTransform.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module.exports = {
process() {
return 'module.exports = {};'
return { code: 'module.exports = {};' }
},
getCacheKey() {
// The output is always the same.
Expand Down
6 changes: 4 additions & 2 deletions testUtils/svgTransform.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ module.exports = {
process(_src, filename) {
const assetFilename = JSON.stringify(path.basename(filename))

return `const React = require('react');
return {
code: `const React = require('react');
module.exports = React.forwardRef((props, ref) => {
return {
$$typeof: Symbol.for('react.element'),
Expand All @@ -18,6 +19,7 @@ module.exports = {
children: ${assetFilename}
})
};
});`
});`,
}
},
}

0 comments on commit ce5fe9b

Please sign in to comment.