-
Notifications
You must be signed in to change notification settings - Fork 114
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 #1049 from jiji14/react-testing-setup
React Component Testing Setup
- Loading branch information
Showing
7 changed files
with
65 additions
and
26 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 |
---|---|---|
@@ -0,0 +1,4 @@ | ||
module.exports = { | ||
presets: ['@babel/preset-env', '@babel/preset-typescript', '@babel/preset-react'], | ||
plugins: ['@babel/plugin-transform-flow-strip-types'], | ||
} |
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 @@ | ||
module.exports = { | ||
testEnvironment: 'jsdom', | ||
testPathIgnorePatterns: [ | ||
"/node_modules/", | ||
"/platforms/", | ||
"/plugins/", | ||
"/lib/", | ||
"/manual_lib/" | ||
], | ||
preset: 'react-native', | ||
transform: { | ||
"^.+\\.(ts|tsx|js|jsx)$": "babel-jest" | ||
}, | ||
transformIgnorePatterns: [ | ||
"node_modules/(?!((jest-)?react-native(-.*)?|@react-native(-community)?)/)" | ||
], | ||
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx'], | ||
moduleDirectories: ["node_modules", "src"], | ||
}; |
This file was deleted.
Oops, something went wrong.
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,30 @@ | ||
/** | ||
* @jest-environment jsdom | ||
*/ | ||
import React from 'react' | ||
import {render, fireEvent, waitFor, screen} from '@testing-library/react-native' | ||
import LoadMoreButton from '../js/diary/list/LoadMoreButton' | ||
|
||
|
||
describe("LoadMoreButton", () => { | ||
it("renders correctly", async () => { | ||
render( | ||
<LoadMoreButton onPressFn={() => {}}>{}</LoadMoreButton> | ||
); | ||
await waitFor(() => { | ||
expect(screen.getByTestId("load-button")).toBeTruthy(); | ||
}); | ||
}); | ||
|
||
it("calls onPressFn when clicked", () => { | ||
const mockFn = jest.fn(); | ||
const { getByTestId } = render( | ||
<LoadMoreButton onPressFn={mockFn}>{}</LoadMoreButton> | ||
); | ||
const loadButton = getByTestId("load-button"); | ||
fireEvent.press(loadButton); | ||
expect(mockFn).toHaveBeenCalled(); | ||
}); | ||
}); | ||
|
||
|
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