forked from flexpool/frontend
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
1,922 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,3 +2,5 @@ | |
. "$(dirname "$0")/_/husky.sh" | ||
|
||
yarn lint | ||
|
||
yarn test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
module.exports = { | ||
collectCoverageFrom: [ | ||
'**/*.{js,jsx,ts,tsx}', | ||
'!**/*.d.ts', | ||
'!**/node_modules/**', | ||
'!<rootDir>/out/**', | ||
'!<rootDir>/.next/**', | ||
'!<rootDir>/*.config.js', | ||
'!<rootDir>/coverage/**', | ||
], | ||
moduleNameMapper: { | ||
// Handle CSS imports (with CSS modules) | ||
// https://jestjs.io/docs/webpack#mocking-css-modules | ||
// '^.+\\.module\\.(css|sass|scss)$': 'identity-obj-proxy', | ||
|
||
// Handle CSS imports (without CSS modules) | ||
// '^.+\\.(css|sass|scss)$': '<rootDir>/__mocks__/styleMock.js', | ||
|
||
// Handle image imports | ||
// https://jestjs.io/docs/webpack#handling-static-assets | ||
// '^.+\\.(png|jpg|jpeg|gif|webp|avif|ico|bmp|svg)$/i': `<rootDir>/__mocks__/fileMock.js`, | ||
|
||
// Handle module aliases | ||
'^@/(.*)$': '<rootDir>/src/$1', | ||
}, | ||
transform: { | ||
// Use babel-jest to transpile tests with the next/babel preset | ||
// https://jestjs.io/docs/configuration#transform-objectstring-pathtotransformer--pathtotransformer-object | ||
'^.+\\.(js|jsx|ts|tsx)$': ['babel-jest', { presets: ['next/babel'] }], | ||
}, | ||
testEnvironment: 'jsdom', | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
...pages/MinerDashboard/Announcements/FlexFarmerAnnouncement/FlexFarmerAnnouncement.test.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import React from 'react'; | ||
import FlexFarmerAnnouncement from './FlexFarmerAnnouncement'; | ||
import { render, screen, waitFor } from '@/utils/test-utils'; | ||
import '@testing-library/jest-dom'; | ||
|
||
describe('<FlexFarmerAnnouncement />', () => { | ||
it('should render correctly', () => { | ||
render(<FlexFarmerAnnouncement />); | ||
expect( | ||
screen.getByRole('link', { name: /learn more about flexfarmer/i }) | ||
).toBeInTheDocument(); | ||
}); | ||
|
||
it('should disappear when x is clicked', async () => { | ||
render(<FlexFarmerAnnouncement />); | ||
|
||
expect( | ||
screen.getByRole('link', { name: /learn more about flexfarmer/i }) | ||
).toBeVisible(); | ||
|
||
screen.getByRole('button', { name: /close/i }).click(); | ||
|
||
await waitFor(() => { | ||
expect( | ||
screen.queryByRole('link', { name: /learn more about flexfarmer/i }) | ||
).not.toBeInTheDocument(); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import { render, RenderOptions } from '@testing-library/react'; | ||
import React from 'react'; | ||
import { QueryClient, QueryClientProvider } from 'react-query'; | ||
|
||
const AlltheProviders = ({ children }: { children?: React.ReactNode }) => { | ||
const queryClient = new QueryClient(); | ||
|
||
return ( | ||
<QueryClientProvider client={queryClient}>{children}</QueryClientProvider> | ||
); | ||
}; | ||
|
||
const customRender = (ui: React.ReactElement, options?: RenderOptions) => { | ||
return render(ui, { wrapper: AlltheProviders, ...options }); | ||
}; | ||
|
||
export * from '@testing-library/react'; | ||
|
||
export { customRender as render }; |
Oops, something went wrong.