-
Notifications
You must be signed in to change notification settings - Fork 111
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #103 from Dprof-in-tech/feat-write-tests
Added frontend testing using Jest
- Loading branch information
Showing
15 changed files
with
686 additions
and
71 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
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,4 @@ | ||
module.exports = { | ||
presets: [['@babel/preset-env', { targets: { node: 'current' } }], '@babel/preset-react'], | ||
}; | ||
|
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,14 @@ | ||
module.exports = { | ||
setupFiles: ['./jest.setup.js'], | ||
transform: { | ||
'^.+\\.[tj]sx?$': 'babel-jest', // Using Babel for transforming JS, JSX, TS, and TSX | ||
}, | ||
moduleNameMapper: { | ||
'\\.svg$': '<rootDir>/test/__mocks__/svgMock.js', | ||
}, | ||
transformIgnorePatterns: [ | ||
'node_modules/(?!(axios|get-starknet)/)' // Ignore transforming node_modules | ||
], | ||
|
||
testEnvironment: 'jsdom', // Use node as the test environment | ||
}; |
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,4 @@ | ||
import { TextEncoder, TextDecoder } from 'util'; | ||
|
||
global.TextEncoder = TextEncoder; | ||
global.TextDecoder = TextDecoder; |
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
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,13 @@ | ||
const mockStarknet = { | ||
isConnected: true, | ||
account: { | ||
deployContract: jest.fn().mockResolvedValue({ | ||
transaction_hash: '0xabc...', | ||
contract_address: '0xdef...' | ||
}), | ||
waitForTransaction: jest.fn().mockResolvedValue(true), | ||
}, | ||
}; | ||
|
||
export const connect = jest.fn().mockResolvedValue(mockStarknet); | ||
|
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,6 @@ | ||
import React from 'react'; | ||
|
||
const SvgMock = React.forwardRef((props, ref) => <span ref={ref} {...props} />); | ||
|
||
export const ReactComponent = SvgMock; | ||
export default SvgMock; |
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 @@ | ||
export const mockBackendUrl = "http://127.0.0.1:8000"; |
Empty file.
Empty file.
Empty file.
Oops, something went wrong.