1
0
mirror of https://github.com/kremalicious/blowfish.git synced 2024-11-24 19:10:14 +01:00
blowfish/tests/Providers.test.jsx

42 lines
1.4 KiB
React
Raw Normal View History

2020-02-25 15:16:44 +01:00
import React from 'react'
2020-10-10 15:37:05 +02:00
import { render, fireEvent, waitFor } from '@testing-library/react'
2020-02-25 15:16:44 +01:00
import AppProvider from '../src/renderer/store/AppProvider'
import PriceProvider from '../src/renderer/store/PriceProvider'
2020-02-26 21:49:11 +01:00
import { PriceContext, AppContext } from '../src/renderer/store/createContext'
2020-02-25 15:16:44 +01:00
import { priceContext } from './__fixtures__/context'
describe('Providers', () => {
2020-02-26 21:49:11 +01:00
describe('PriceProvider', () => {
it('renders without crashing', async () => {
const { getByText } = render(
<PriceProvider>
<PriceContext.Consumer>
{({ priceChanges }) => JSON.stringify(priceChanges)}
</PriceContext.Consumer>
</PriceProvider>
)
expect(getByText(/eur/)).toBeInTheDocument()
})
2020-02-25 15:16:44 +01:00
})
2020-02-26 21:49:11 +01:00
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>
)
2020-10-10 15:37:05 +02:00
await waitFor(() => getByText('Click'))
2020-02-26 21:49:11 +01:00
expect(getByText('Click')).toBeInTheDocument()
fireEvent.click(getByText('Click'))
})
2020-02-25 15:16:44 +01:00
})
})