-
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.
Merge branch 'main' into LUN-351-separeted-words-wrong
- Loading branch information
Showing
28 changed files
with
510 additions
and
504 deletions.
There are no files selected for viewing
6 changes: 6 additions & 0 deletions
6
release-notes/unreleased/LUN-131-logic-for-unlocking-exercises-2.yml
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,6 @@ | ||
issue_key: LUN-131 | ||
show_in_stores: true | ||
platforms: | ||
- android | ||
- ios | ||
de: Freischaltungsmechanismus für Übungen |
6 changes: 6 additions & 0 deletions
6
release-notes/unreleased/LUN-131-logic-for-unlocking-exercises.yml
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,6 @@ | ||
issue_key: LUN-131 | ||
show_in_stores: true | ||
platforms: | ||
- android | ||
- ios | ||
de: Fortschrittsanzeige für Übungen |
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,45 @@ | ||
import React from 'react' | ||
import { FlatList } from 'react-native' | ||
import styled from 'styled-components/native' | ||
|
||
import { Document } from '../constants/endpoints' | ||
import labels from '../constants/labels.json' | ||
import Title from './Title' | ||
import VocabularyListItem from './VocabularyListItem' | ||
|
||
const Root = styled.View` | ||
background-color: ${props => props.theme.colors.background}; | ||
height: 100%; | ||
width: 100%; | ||
padding: 0 ${props => props.theme.spacings.sm}; | ||
` | ||
|
||
interface VocabularyListScreenProps { | ||
documents: Document[] | ||
onItemPress: (index: number) => void | ||
} | ||
|
||
const VocabularyList = ({ documents, onItemPress }: VocabularyListScreenProps): JSX.Element => { | ||
const renderItem = ({ item, index }: { item: Document; index: number }): JSX.Element => ( | ||
<VocabularyListItem document={item} onPress={() => onItemPress(index)} /> | ||
) | ||
|
||
return ( | ||
<Root> | ||
<FlatList | ||
ListHeaderComponent={ | ||
<Title | ||
title={labels.exercises.vocabularyList.title} | ||
description={`${documents.length} ${documents.length === 1 ? labels.general.word : labels.general.words}`} | ||
/> | ||
} | ||
data={documents} | ||
renderItem={renderItem} | ||
keyExtractor={item => `${item.id}`} | ||
showsVerticalScrollIndicator={false} | ||
/> | ||
</Root> | ||
) | ||
} | ||
|
||
export default VocabularyList |
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,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 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.