-
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.
Added Tests for Home and Login page, getting out of time so could not…
… write more, spent most of time fixing react-native spacific issues with jest
- Loading branch information
Showing
23 changed files
with
201 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 @@ | ||
export default from '@react-native-community/async-storage/jest/async-storage-mock'; |
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,2 @@ | ||
module.exports = "SvgMock"; | ||
// module.exports.ReactComponent = "SvgMock"; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import React from 'react'; | ||
import { cleanup, fireEvent } from 'react-native-testing-library'; | ||
import 'jest-styled-components'; | ||
import { customRender } from './utils'; | ||
import App from 'components/App'; | ||
import renderer from 'react-test-renderer'; | ||
|
||
|
||
afterEach(cleanup); | ||
|
||
jest.mock('redux-persist/integration/react', () => ({ | ||
PersistGate: props => props.children, | ||
})); | ||
|
||
it('renders correctly', () => { | ||
const { getByText, baseElement } = customRender( | ||
<App />, | ||
); | ||
expect(baseElement).toMatchSnapshot() | ||
}); |
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,42 @@ | ||
import React from 'react'; | ||
import { render, cleanup, fireEvent } from 'react-native-testing-library'; | ||
import 'jest-styled-components'; | ||
import { customRender } from './utils'; | ||
|
||
import Home from 'components/Home/Home'; | ||
|
||
afterEach(cleanup); | ||
|
||
|
||
|
||
describe('<Home />', () => { | ||
it('should have title text', () => { | ||
const { getByText, baseElement } = customRender( | ||
<Home /> | ||
); | ||
expect(getByText('Currency Converter')).toBeTruthy() | ||
expect(baseElement).toMatchSnapshot() | ||
}); | ||
}); | ||
|
||
// test('renders correctly', () => { | ||
// const tree = renderer.create(<Home />).toJSON(); | ||
// expect(tree).toMatchSnapshot(); | ||
// }); | ||
|
||
|
||
// test('examples of some things', async () => { | ||
// const { getByTestId, getByText, queryByTestId, baseElement } = render(<Home />); | ||
// // const famousWomanInHistory = 'Ada Lovelace'; | ||
|
||
// // const input = getByTestId('input'); | ||
// // fireEvent.changeText(input, famousWomanInHistory); | ||
|
||
// // const button = getByText('Print Username'); | ||
// // fireEvent.press(button); | ||
|
||
// // await wait(() => expect(queryByTestId('printed-username')).toBeTruthy()); | ||
|
||
// // expect(getByTestId('printed-username').props.children).toBe(famousWomanInHistory); | ||
// // expect(baseElement).toMatchSnapshot(); | ||
// }); |
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 React from 'react'; | ||
import { cleanup } from 'react-native-testing-library'; | ||
import 'jest-styled-components'; | ||
import { customRender } from './utils'; | ||
|
||
import Login from 'components/Login/Login'; | ||
|
||
afterEach(cleanup); | ||
|
||
|
||
|
||
describe('<Login />', () => { | ||
it('should render', () => { | ||
const { getByText, baseElement } = customRender( | ||
<Login /> | ||
); | ||
expect(baseElement).toMatchSnapshot() | ||
}); | ||
}); |
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,3 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`renders correctly 1`] = `undefined`; |
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,3 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`<Home /> should have title text 1`] = `undefined`; |
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,3 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`<Login /> should render 1`] = `undefined`; |
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,39 @@ | ||
import React from 'react'; | ||
import { render } from 'react-native-testing-library'; | ||
import { Provider } from 'react-redux'; | ||
import configureStore from 'redux-mock-store'; | ||
|
||
import { THEMES_MAP } from 'constants'; | ||
import { AUTH_STATES } from 'constants'; | ||
|
||
export const initialState = { | ||
appReducer: { | ||
theme: THEMES_MAP.Blue, | ||
authState: AUTH_STATES.LOGGED_OUT, | ||
loginLoading: false, | ||
favorites: {}, | ||
}, | ||
currencyReducer: { | ||
baseCurrency: 'USD', | ||
targetCurrency: 'AUD', | ||
baseCurrencyValue: 0, | ||
targetCurrencyValue: 0, | ||
rates: {}, | ||
} | ||
} | ||
|
||
const mockStore = configureStore([]); | ||
const mockedStore = mockStore(initialState); | ||
export const customRender = (ui, store = mockedStore) => { | ||
return render( | ||
<Provider store={store}> | ||
{ui} | ||
</Provider>, | ||
{ | ||
createNodeMock: (element) => { | ||
if (element.type === PersistGate) { return element.props.children } | ||
return null; | ||
} | ||
} | ||
) | ||
} |
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 |
---|---|---|
@@ -1,3 +1,5 @@ | ||
rootProject.name = 'CurrencyConverter' | ||
include ':@react-native-community_async-storage' | ||
project(':@react-native-community_async-storage').projectDir = new File(rootProject.projectDir, '../node_modules/@react-native-community/async-storage/android') | ||
apply from: file("../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesSettingsGradle(settings) | ||
include ':app' |
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
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
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
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