-
-
Notifications
You must be signed in to change notification settings - Fork 266
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(suite-native): introduce component tests
- Loading branch information
Showing
15 changed files
with
123 additions
and
55 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 @@ | ||
const { ...baseConfig } = require('../../jest.config.native'); | ||
module.exports = { | ||
...baseConfig, | ||
}; |
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
17 changes: 17 additions & 0 deletions
17
suite-native/accounts/src/components/__tests__/AccountLabelFieldHint.comp.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,17 @@ | ||
import { render, renderHook } from '@suite-native/test-utils'; | ||
|
||
import { AccountLabelFieldHint, AccountLabelFieldHintProps } from '../AccountLabelFieldHint'; | ||
import { useAccountLabelForm } from '../../hooks/useAccountLabelForm'; | ||
|
||
describe('AccountLabelFieldHint', () => { | ||
const renderComponent = (props: AccountLabelFieldHintProps) => | ||
render(<AccountLabelFieldHint {...props} />); | ||
|
||
test('should render', () => { | ||
const { result } = renderHook(() => useAccountLabelForm('Account label')); | ||
|
||
const { getByText } = renderComponent({ formControl: result.current.control }); | ||
|
||
expect(getByText('13 / 30 letters')).toBeDefined(); | ||
}); | ||
}); |
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 @@ | ||
const { ...baseConfig } = require('../../jest.config.native'); | ||
module.exports = { | ||
...baseConfig, | ||
}; |
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,29 @@ | ||
import { Text } from 'react-native'; | ||
|
||
import { render } from '@suite-native/test-utils'; | ||
|
||
import { Card, CardProps } from '../Card'; | ||
|
||
describe('Card', () => { | ||
const renderComponent = (props: Omit<CardProps, 'children'>) => { | ||
const cardProps = { | ||
children: <Text>hello</Text>, | ||
...props, | ||
} as CardProps; | ||
|
||
return render(<Card {...cardProps} />); | ||
}; | ||
|
||
it('should render children prop', () => { | ||
const { getByText } = renderComponent({}); | ||
|
||
expect(getByText('hello')).toBeDefined(); | ||
}); | ||
|
||
it('should render children and alert, when alert props are specified', () => { | ||
const { getByText } = renderComponent({ alertTitle: 'alert', alertVariant: 'info' }); | ||
|
||
expect(getByText('hello')).toBeDefined(); | ||
expect(getByText('alert')).toBeDefined(); | ||
}); | ||
}); |
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 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,37 @@ | ||
import { ReactElement } from 'react'; | ||
|
||
import { render as origRender } from '@testing-library/react-native'; | ||
|
||
import { Provider } from './Provider'; | ||
|
||
type Parameters<TParams> = TParams extends (...args: infer TParamsInferred) => any | ||
? TParamsInferred | ||
: never; | ||
|
||
export const render = ( | ||
element: ReactElement, | ||
{ wrapper: WrapperComponent, ...options }: Parameters<typeof origRender>[1] = {}, | ||
): ReturnType<typeof origRender> => { | ||
const wrapperWithProvider = WrapperComponent | ||
? ({ children }: { children: ReactElement }) => ( | ||
<Provider> | ||
<WrapperComponent>{children}</WrapperComponent> | ||
</Provider> | ||
) | ||
: Provider; | ||
|
||
return origRender(element, { | ||
wrapper: wrapperWithProvider, | ||
...options, | ||
}); | ||
}; | ||
|
||
export { | ||
act, | ||
cleanup, | ||
fireEvent, | ||
renderHook, | ||
screen, | ||
waitFor, | ||
waitForElementToBeRemoved, | ||
} from '@testing-library/react-native'; |
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