mirror of
https://github.com/Jellify-Music/App.git
synced 2026-04-29 06:59:30 -05:00
8a69960a97
Adds a revamped library page - where items aren't limited to just a user's favorites. Fixes scrubber lag in player screen Reorganizes component folder into separate components - providers - screens for better visibility and separation of concerns Addresses some styling issues with text and font legibility
58 lines
1.4 KiB
TypeScript
58 lines
1.4 KiB
TypeScript
import { render, screen, waitFor } from '@testing-library/react-native'
|
|
import { JellifyProvider, useJellifyContext } from '../src/providers'
|
|
import { Text, View } from 'react-native'
|
|
import { MMKVStorageKeys } from '../src/enums/mmkv-storage-keys'
|
|
import { storage } from '../src/constants/storage'
|
|
import { useEffect } from 'react'
|
|
|
|
const JellifyConsumer = () => {
|
|
const { server, user, library } = useJellifyContext()
|
|
|
|
return (
|
|
<View>
|
|
<Text testID='api-base-path'>{server?.url}</Text>
|
|
<Text testID='user-name'>{user?.name}</Text>
|
|
<Text testID='library-name'>{library?.musicLibraryName}</Text>
|
|
</View>
|
|
)
|
|
}
|
|
|
|
test(`${JellifyProvider.name} renders correctly`, async () => {
|
|
storage.set(
|
|
MMKVStorageKeys.Server,
|
|
JSON.stringify({
|
|
url: 'http://localhost:8096',
|
|
}),
|
|
)
|
|
|
|
storage.set(
|
|
MMKVStorageKeys.User,
|
|
JSON.stringify({
|
|
name: 'Violet Caulfield',
|
|
}),
|
|
)
|
|
|
|
storage.set(
|
|
MMKVStorageKeys.Library,
|
|
JSON.stringify({
|
|
musicLibraryName: 'Music Library',
|
|
}),
|
|
)
|
|
|
|
render(
|
|
<JellifyProvider>
|
|
<JellifyConsumer />
|
|
</JellifyProvider>,
|
|
)
|
|
|
|
const apiBasePath = screen.getByTestId('api-base-path')
|
|
const userName = screen.getByTestId('user-name')
|
|
const libraryName = screen.getByTestId('library-name')
|
|
|
|
await waitFor(() => {
|
|
expect(apiBasePath.props.children).toBe('http://localhost:8096')
|
|
expect(userName.props.children).toBe('Violet Caulfield')
|
|
expect(libraryName.props.children).toBe('Music Library')
|
|
})
|
|
})
|