-
Notifications
You must be signed in to change notification settings - Fork 3
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 #90 from BouyguesTelecom/native/tests
Fix and add test on native
- Loading branch information
Showing
97 changed files
with
1,811 additions
and
145 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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,3 @@ | ||
module.exports = { | ||
presets: ['module:metro-react-native-babel-preset'], | ||
} |
27 changes: 27 additions & 0 deletions
27
packages/react/components/accordion/body/test/AccordionBody.native.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,27 @@ | ||
import { render, screen, userEvent } from '@testing-library/react-native' | ||
import * as React from 'react' | ||
import Text from '../../../text/Text.native' | ||
import Accordion from '../../Accordion.native' | ||
import AccordionBody from '../../body/AccordionBody.native' | ||
import AccordionHeader from '../../header/AccordionHeader.native' | ||
import AccordionItem from '../../item/AccordionItem.native' | ||
|
||
describe('Accordion', () => { | ||
it('should render correctly', () => { | ||
render( | ||
<Accordion> | ||
<AccordionItem active={false}> | ||
<AccordionHeader> | ||
<Text>header</Text> | ||
</AccordionHeader> | ||
<AccordionBody> | ||
<Text>body</Text> | ||
</AccordionBody> | ||
</AccordionItem> | ||
</Accordion>, | ||
) | ||
|
||
expect(screen.getByText('body')).toBeOnTheScreen() | ||
}) | ||
|
||
}) |
27 changes: 27 additions & 0 deletions
27
packages/react/components/accordion/header/test/AccordionHeader.native.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,27 @@ | ||
import { render, screen, userEvent } from '@testing-library/react-native' | ||
import * as React from 'react' | ||
import Text from '../../../text/Text.native' | ||
import Accordion from '../../Accordion.native' | ||
import AccordionBody from '../../body/AccordionBody.native' | ||
import AccordionHeader from '../AccordionHeader.native' | ||
import AccordionItem from '../../item/AccordionItem.native' | ||
|
||
describe('Accordion', () => { | ||
it('should render correctly', () => { | ||
render( | ||
<Accordion> | ||
<AccordionItem active={false}> | ||
<AccordionHeader> | ||
<Text>header</Text> | ||
</AccordionHeader> | ||
<AccordionBody> | ||
<Text>body</Text> | ||
</AccordionBody> | ||
</AccordionItem> | ||
</Accordion>, | ||
) | ||
|
||
expect(screen.getByText('header')).toBeOnTheScreen() | ||
}) | ||
|
||
}) |
90 changes: 90 additions & 0 deletions
90
packages/react/components/accordion/item/test/AccordionItem.native.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,90 @@ | ||
import { render, screen, userEvent } from '@testing-library/react-native' | ||
import * as React from 'react' | ||
import Text from '../../../text/Text.native' | ||
import Accordion from '../../Accordion.native' | ||
import AccordionBody from '../../body/AccordionBody.native' | ||
import AccordionHeader from '../../header/AccordionHeader.native' | ||
import AccordionItem from '../../item/AccordionItem.native' | ||
|
||
jest.useFakeTimers() | ||
|
||
describe('Accordion', () => { | ||
it('should render correctly', () => { | ||
render( | ||
<Accordion> | ||
<AccordionItem active={false}> | ||
<AccordionHeader> | ||
<Text>header</Text> | ||
</AccordionHeader> | ||
<AccordionBody> | ||
<Text>body</Text> | ||
</AccordionBody> | ||
</AccordionItem> | ||
</Accordion>, | ||
) | ||
|
||
expect(screen.getByText('header')).toBeOnTheScreen() | ||
}) | ||
|
||
test('should be disabled', async () => { | ||
const onClick = jest.fn() | ||
|
||
render( | ||
<Accordion> | ||
<AccordionItem disabled onClick={onClick}> | ||
<AccordionHeader> | ||
<Text>header</Text> | ||
</AccordionHeader> | ||
<AccordionBody> | ||
<Text>body</Text> | ||
</AccordionBody> | ||
</AccordionItem> | ||
</Accordion>, | ||
) | ||
const user = userEvent.setup() | ||
await user.press(screen.getByText('header')) | ||
expect(onClick).not.toHaveBeenCalled() | ||
}) | ||
|
||
test('should execute onOpen function', async () => { | ||
const onOpen = jest.fn() | ||
const user = userEvent.setup() | ||
|
||
render( | ||
<Accordion> | ||
<AccordionItem id={'accordion'} onOpen={onOpen}> | ||
<AccordionHeader> | ||
<Text>header</Text> | ||
</AccordionHeader> | ||
<AccordionBody> | ||
<Text>body</Text> | ||
</AccordionBody> | ||
</AccordionItem> | ||
</Accordion>, | ||
) | ||
|
||
await user.press(screen.getByTestId('accordion')) | ||
expect(onOpen).toHaveBeenCalled() | ||
}) | ||
|
||
test('should execute onClose function', async () => { | ||
const onClose = jest.fn() | ||
const user = userEvent.setup() | ||
|
||
render( | ||
<Accordion> | ||
<AccordionItem active id={'accordion'} onClose={onClose}> | ||
<AccordionHeader> | ||
<Text>header</Text> | ||
</AccordionHeader> | ||
<AccordionBody> | ||
<Text>body</Text> | ||
</AccordionBody> | ||
</AccordionItem> | ||
</Accordion>, | ||
) | ||
|
||
await user.press(screen.getByTestId('accordion')) | ||
expect(onClose).toHaveBeenCalled() | ||
}) | ||
}) |
19 changes: 19 additions & 0 deletions
19
packages/react/components/accordion/test/Accordion.native.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,19 @@ | ||
import { render } from '@testing-library/react-native' | ||
import * as React from 'react' | ||
import Accordion from '../Accordion.native' | ||
import AccordionBody from '../body/AccordionBody.native' | ||
import AccordionHeader from '../header/AccordionHeader.native' | ||
import AccordionItem from '../item/AccordionItem.native' | ||
|
||
describe('Accordion', () => { | ||
it('should render correctly', () => { | ||
render( | ||
<Accordion> | ||
<AccordionItem> | ||
<AccordionHeader>Accordion Header</AccordionHeader> | ||
<AccordionBody> content </AccordionBody> | ||
</AccordionItem> | ||
</Accordion>, | ||
) | ||
}) | ||
}) |
20 changes: 20 additions & 0 deletions
20
packages/react/components/alert/test/Alert.native.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,20 @@ | ||
import { render, screen } from '@testing-library/react-native' | ||
import * as React from 'react' | ||
import { AlertState } from '../../../objects' | ||
import Alert from '../Alert.native' | ||
|
||
describe('Alert', () => { | ||
it('should render correctly', () => { | ||
render( | ||
<Alert | ||
testId={'alert'} | ||
display | ||
alert={AlertState.INFO} | ||
title='Alert information' | ||
description='Lorem Ipsum is simply dummy text of the printing and type..' | ||
/>, | ||
) | ||
|
||
expect(screen.getByText('Alert information')).toBeOnTheScreen() | ||
}) | ||
}) |
19 changes: 19 additions & 0 deletions
19
packages/react/components/autolayout/test/AutoLayout.native.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,19 @@ | ||
import { render, screen } from '@testing-library/react-native' | ||
import * as React from 'react' | ||
import Text from '../../text/Text.native' | ||
import AutoLayout from '../AutoLayout' | ||
import AutoLayoutWrapper from '../AutoLayoutWrapper' | ||
|
||
describe('AutoLayout component', () => { | ||
it('should render its children', () => { | ||
render( | ||
<AutoLayoutWrapper autolayout={false}> | ||
<AutoLayout> | ||
<Text>Hello world!</Text> | ||
</AutoLayout> | ||
</AutoLayoutWrapper>, | ||
) | ||
|
||
expect(screen.getByText('Hello world!')).toBeOnTheScreen() | ||
}) | ||
}) |
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
37 changes: 37 additions & 0 deletions
37
packages/react/components/badge/test/Badge.native.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,37 @@ | ||
import { render, screen, userEvent } from '@testing-library/react-native' | ||
import * as React from 'react' | ||
import Text from '../../text/Text.native' | ||
import Badge from '../Badge.native' | ||
|
||
jest.useFakeTimers() | ||
|
||
describe('Badge component', () => { | ||
test('should contain toto as text', () => { | ||
render( | ||
<Badge> | ||
<Text>toto</Text> | ||
</Badge>, | ||
) | ||
expect(screen.getByText('toto')).toBeOnTheScreen() | ||
}) | ||
|
||
test('should have a text content', () => { | ||
render(<Badge textContent={'TEXT'}>TEXTCONTENT</Badge>) | ||
expect(screen.getByText('TEXT')).toBeOnTheScreen() | ||
}) | ||
|
||
test('should have a content', () => { | ||
render(<Badge content={'CONTENT'}>TEXT</Badge>) | ||
expect(screen.getByText('CONTENT')).toBeOnTheScreen() | ||
}) | ||
|
||
test('should onClick attribut work', async () => { | ||
const onClick = jest.fn() | ||
const user = userEvent.setup() | ||
|
||
render(<Badge testId="badge" onClick={onClick}>DEFAULT</Badge>) | ||
|
||
await user.press(screen.getByTestId('badge')) | ||
expect(onClick).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
Oops, something went wrong.