-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
LUN-357: Use own vocabulary detail route instead of modal
- Loading branch information
1 parent
fa4f629
commit c4dfe41
Showing
15 changed files
with
191 additions
and
260 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
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,55 @@ | ||
import { fireEvent } from '@testing-library/react-native' | ||
import React from 'react' | ||
|
||
import labels from '../../constants/labels.json' | ||
import DocumentBuilder from '../../testing/DocumentBuilder' | ||
import { mockUseLoadAsyncWithData } from '../../testing/mockUseLoadFromEndpoint' | ||
import render from '../../testing/render' | ||
import VocabularyList from '../VocabularyList' | ||
|
||
jest.mock('../AudioPlayer', () => { | ||
const Text = require('react-native').Text | ||
return () => <Text>AudioPlayer</Text> | ||
}) | ||
|
||
describe('VocabularyList', () => { | ||
beforeEach(() => { | ||
jest.clearAllMocks() | ||
}) | ||
|
||
const onItemPress = jest.fn() | ||
const documents = new DocumentBuilder(2).build() | ||
|
||
it('should display vocabulary list', () => { | ||
mockUseLoadAsyncWithData(documents) | ||
|
||
const { getByText, getAllByText, getAllByTestId } = render( | ||
<VocabularyList documents={documents} onItemPress={onItemPress} /> | ||
) | ||
|
||
expect(getByText(labels.exercises.vocabularyList.title)).toBeTruthy() | ||
expect(getByText(`2 ${labels.general.words}`)).toBeTruthy() | ||
expect(getByText('Der')).toBeTruthy() | ||
expect(getByText('Spachtel')).toBeTruthy() | ||
expect(getByText('Das')).toBeTruthy() | ||
expect(getByText('Auto')).toBeTruthy() | ||
expect(getAllByText('AudioPlayer')).toHaveLength(2) | ||
expect(getAllByTestId('image')).toHaveLength(2) | ||
}) | ||
|
||
it('should call onItemPress with correct index', () => { | ||
const { getByText } = render(<VocabularyList documents={documents} onItemPress={onItemPress} />) | ||
|
||
expect(onItemPress).toHaveBeenCalledTimes(0) | ||
|
||
fireEvent.press(getByText('Auto')) | ||
|
||
expect(onItemPress).toHaveBeenCalledTimes(1) | ||
expect(onItemPress).toHaveBeenCalledWith(1) | ||
|
||
fireEvent.press(getByText('Spachtel')) | ||
|
||
expect(onItemPress).toHaveBeenCalledTimes(2) | ||
expect(onItemPress).toHaveBeenCalledWith(0) | ||
}) | ||
}) |
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
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
Oops, something went wrong.