mirror of
https://github.com/shlinkio/shlink-web-client.git
synced 2026-10-20 04:34:11 +00:00
Replace direct rendering with react testing library by vitest-browser-react
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import { render } from '@testing-library/react';
|
||||
import { fromPartial } from '@total-typescript/shoehorn';
|
||||
import { ContainerProvider, useDependencies } from '../../src/container/context';
|
||||
import { render } from '../__helpers__/setUpTest.tsx';
|
||||
|
||||
describe('context', () => {
|
||||
describe('useDependencies', () => {
|
||||
@@ -12,24 +12,24 @@ describe('context', () => {
|
||||
return null;
|
||||
}
|
||||
|
||||
it('throws when used outside of ContainerProvider', () => {
|
||||
expect(() => render(<TestComponent name="foo" />)).toThrow(
|
||||
it('throws when used outside of ContainerProvider', async () => {
|
||||
await expect(() => render(<TestComponent name="foo" />)).rejects.toThrow(
|
||||
'You cannot use "useDependencies" outside of a ContainerProvider',
|
||||
);
|
||||
});
|
||||
|
||||
it('throws when requested dependency is not found in container', () => {
|
||||
expect(() =>
|
||||
it('throws when requested dependency is not found in container', async () => {
|
||||
await expect(() =>
|
||||
render(
|
||||
<ContainerProvider value={fromPartial({})}>
|
||||
<TestComponent name="foo" />
|
||||
</ContainerProvider>,
|
||||
),
|
||||
).toThrow('Dependency with name "foo" not found in container');
|
||||
).rejects.toThrow('Dependency with name "foo" not found in container');
|
||||
});
|
||||
|
||||
it('gets dependency from container', () => {
|
||||
render(
|
||||
it('gets dependency from container', async () => {
|
||||
await render(
|
||||
<ContainerProvider value={fromPartial({ foo: 'the dependency' })}>
|
||||
<TestComponent name="foo" />
|
||||
</ContainerProvider>,
|
||||
|
||||
Reference in New Issue
Block a user