generated from solidjs-community/solid-lib-starter
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathprovider.test.tsx
50 lines (43 loc) · 1.17 KB
/
provider.test.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
import { describe, it, expect } from "vitest";
import { screen, render } from "solid-testing-library";
import IntlProvider from "../src/provider";
const en = {
"app.greeting": "Welcome back!",
};
const es = {
"app.greeting": "¡Bienvenido de nuevo!",
};
describe("<IntlProvider />", () => {
describe("exceptions", () => {
it("should not throw when required props are correctly setup", () => {
expect(() =>
render(() => (
<IntlProvider locale="en" messages={en}>
<div>lorem ipsum</div>
</IntlProvider>
)),
).not.toThrow();
});
it("should not throw when locale is missing", () => {
expect(() =>
render(() => (
// @ts-ignore
<IntlProvider messages={{}}>
<div>lorem ipsum</div>
</IntlProvider>
)),
).toThrow("locale");
});
});
describe("behaviour", () => {
it("should render children", () => {
const text = "lorem ipsum";
render(() => (
<IntlProvider locale="en" messages={en}>
<div>{text}</div>
</IntlProvider>
));
expect(screen.getByText(text)).toBeInTheDocument();
});
});
});