mirror of
https://github.com/kremalicious/blowfish.git
synced 2024-12-30 16:47:52 +01:00
48 lines
1.4 KiB
JavaScript
48 lines
1.4 KiB
JavaScript
import React from 'react'
|
|
import {
|
|
render,
|
|
waitForElementToBeRemoved,
|
|
fireEvent,
|
|
wait
|
|
} from '@testing-library/react'
|
|
import AppProvider from '../src/renderer/store/AppProvider'
|
|
import PriceProvider from '../src/renderer/store/PriceProvider'
|
|
import { PriceContext, AppContext } from '../src/renderer/store/createContext'
|
|
import { priceContext } from './__fixtures__/context'
|
|
|
|
describe('Providers', () => {
|
|
describe('PriceProvider', () => {
|
|
it('renders without crashing', async () => {
|
|
const { getByText } = render(
|
|
<PriceProvider>
|
|
<PriceContext.Consumer>
|
|
{({ priceChanges }) => JSON.stringify(priceChanges)}
|
|
</PriceContext.Consumer>
|
|
</PriceProvider>
|
|
)
|
|
await waitForElementToBeRemoved(() => getByText(/"eur":0/))
|
|
expect(getByText(/eur/)).toBeInTheDocument()
|
|
})
|
|
})
|
|
|
|
describe('AppProvider', () => {
|
|
it('renders without crashing', async () => {
|
|
const { getByText } = render(
|
|
<PriceContext.Provider value={priceContext}>
|
|
<AppProvider>
|
|
<AppContext.Consumer>
|
|
{({ toggleCurrencies }) => (
|
|
<button onClick={() => toggleCurrencies('eur')}>Click</button>
|
|
)}
|
|
</AppContext.Consumer>
|
|
</AppProvider>
|
|
</PriceContext.Provider>
|
|
)
|
|
await wait(() => getByText('Click'))
|
|
expect(getByText('Click')).toBeInTheDocument()
|
|
|
|
fireEvent.click(getByText('Click'))
|
|
})
|
|
})
|
|
})
|