-
-
Notifications
You must be signed in to change notification settings - Fork 260
Expand file tree
/
Copy pathButton_.test.res
More file actions
82 lines (61 loc) · 2.11 KB
/
Button_.test.res
File metadata and controls
82 lines (61 loc) · 2.11 KB
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
open Vitest
test("renders PrimaryRed button", async () => {
await viewport(1440, 500)
let screen = await render(
<div dataTestId="button-wrapper">
<Button kind=PrimaryRed> {React.string("Click Me")} </Button>
</div>,
)
let btn = await screen->getByText("Click Me")
await element(btn)->toBeVisible
let wrapper = await screen->getByTestId("button-wrapper")
await element(wrapper)->toMatchScreenshot("button-primary-red")
})
test("renders PrimaryBlue button", async () => {
await viewport(1440, 500)
let screen = await render(
<div dataTestId="button-wrapper">
<Button kind=PrimaryBlue> {React.string("Blue Action")} </Button>
</div>,
)
let btn = await screen->getByText("Blue Action")
await element(btn)->toBeVisible
let wrapper = await screen->getByTestId("button-wrapper")
await element(wrapper)->toMatchScreenshot("button-primary-blue")
})
test("renders SecondaryRed button", async () => {
await viewport(1440, 500)
let screen = await render(
<div dataTestId="button-wrapper">
<Button kind=SecondaryRed> {React.string("Secondary")} </Button>
</div>,
)
let btn = await screen->getByText("Secondary")
await element(btn)->toBeVisible
let wrapper = await screen->getByTestId("button-wrapper")
await element(wrapper)->toMatchScreenshot("button-secondary-red")
})
test("renders Small button", async () => {
await viewport(1440, 500)
let screen = await render(
<div dataTestId="button-wrapper">
<Button size=Small> {React.string("Small Button")} </Button>
</div>,
)
let btn = await screen->getByText("Small Button")
await element(btn)->toBeVisible
let wrapper = await screen->getByTestId("button-wrapper")
await element(wrapper)->toMatchScreenshot("button-small")
})
test("calls onClick when clicked", async () => {
await viewport(1440, 500)
let handleClick = fn()
let screen = await render(
<div dataTestId="button-wrapper">
<Button onClick=handleClick> {React.string("Clickable")} </Button>
</div>,
)
let btn = await screen->getByText("Clickable")
await btn->click
expect(handleClick)->toHaveBeenCalled
})