-
-
Notifications
You must be signed in to change notification settings - Fork 260
Expand file tree
/
Copy pathSyntaxLookup_.test.res
More file actions
173 lines (142 loc) · 5.02 KB
/
SyntaxLookup_.test.res
File metadata and controls
173 lines (142 loc) · 5.02 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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
open ReactRouter
open Vitest
let mockItems: array<SyntaxLookup.item> = [
{
id: "as-decorator",
keywords: ["as", "decorator"],
name: "@as",
summary: "This is the `@as` decorator.",
category: Decorators,
status: Active,
href: "decorator_as",
},
{
id: "module-decorator",
keywords: ["module", "decorator"],
name: "@module",
summary: "This is the `@module` decorator.",
category: Decorators,
status: Active,
href: "decorator_module",
},
{
id: "pipe-operator",
keywords: ["pipe", "operator"],
name: "->",
summary: "The pipe operator.",
category: Operators,
status: Active,
href: "operators_pipe",
},
{
id: "deprecated-send-pipe",
keywords: ["send", "pipe", "deprecated"],
name: "|>",
summary: "The deprecated pipe operator.",
category: Operators,
status: Deprecated,
href: "operators_deprecated_pipe",
},
]
test("desktop syntax lookup renders categories and tags", async () => {
await viewport(1440, 900)
let screen = await render(
<BrowserRouter>
<div dataTestId="syntax-lookup-wrapper">
<SyntaxLookup mdxSources=mockItems />
</div>
</BrowserRouter>,
)
let decoratorsHeading = await screen->getByText("Decorators")
await element(decoratorsHeading)->toBeVisible
let asTag = await screen->getByText("@as")
await element(asTag)->toBeVisible
let moduleTag = await screen->getByText("@module")
await element(moduleTag)->toBeVisible
let operatorsHeading = await screen->getByText("Operators")
await element(operatorsHeading)->toBeVisible
let wrapper = await screen->getByTestId("syntax-lookup-wrapper")
await element(wrapper)->toMatchScreenshot("desktop-syntax-lookup")
})
test("desktop syntax lookup with active item shows detail box", async () => {
await viewport(1440, 900)
let screen = await render(
<BrowserRouter>
<div dataTestId="syntax-lookup-wrapper">
<SyntaxLookup mdxSources=mockItems activeItem={mockItems->Array.getUnsafe(0)}>
<div> {React.string("Detail content for @as decorator.")} </div>
</SyntaxLookup>
</div>
</BrowserRouter>,
)
let detail = await screen->getByText("Detail content for @as decorator.")
await element(detail)->toBeVisible
let wrapper = await screen->getByTestId("syntax-lookup-wrapper")
await element(wrapper)->toMatchScreenshot("desktop-syntax-lookup-active")
})
test("mobile syntax lookup", async () => {
await viewport(600, 1200)
let screen = await render(
<BrowserRouter>
<div dataTestId="syntax-lookup-wrapper">
<SyntaxLookup mdxSources=mockItems />
</div>
</BrowserRouter>,
)
let decoratorsHeading = await screen->getByText("Decorators")
await element(decoratorsHeading)->toBeVisible
let asTag = await screen->getByText("@as")
await element(asTag)->toBeVisible
let moduleTag = await screen->getByText("@module")
await element(moduleTag)->toBeVisible
let operatorsHeading = await screen->getByText("Operators")
await element(operatorsHeading)->toBeVisible
let wrapper = await screen->getByTestId("syntax-lookup-wrapper")
await element(wrapper)->toMatchScreenshot("mobile-syntax-lookup")
})
test("deprecated items show with line-through styling", async () => {
await viewport(1440, 900)
let screen = await render(
<BrowserRouter>
<div dataTestId="syntax-lookup-wrapper">
<SyntaxLookup mdxSources=mockItems />
</div>
</BrowserRouter>,
)
let deprecatedTag = await screen->getByText("|>")
await element(deprecatedTag)->toBeVisible
let wrapper = await screen->getByTestId("syntax-lookup-wrapper")
await element(wrapper)->toMatchScreenshot("desktop-syntax-lookup-deprecated")
})
test("syntax lookup detail box shows summary", async () => {
await viewport(1440, 900)
let screen = await render(
<BrowserRouter>
<div dataTestId="syntax-lookup-wrapper">
<SyntaxLookup mdxSources=mockItems activeItem={mockItems->Array.getUnsafe(2)}>
<div> {React.string("Detailed documentation about the pipe operator.")} </div>
</SyntaxLookup>
</div>
</BrowserRouter>,
)
let detail = await screen->getByText("Detailed documentation about the pipe operator.")
await element(detail)->toBeVisible
let wrapper = await screen->getByTestId("syntax-lookup-wrapper")
await element(wrapper)->toMatchScreenshot("desktop-syntax-lookup-pipe-detail")
})
test("mobile syntax lookup with active item", async () => {
await viewport(600, 1200)
let screen = await render(
<BrowserRouter>
<div dataTestId="syntax-lookup-wrapper">
<SyntaxLookup mdxSources=mockItems activeItem={mockItems->Array.getUnsafe(0)}>
<div> {React.string("Detail content for @as decorator.")} </div>
</SyntaxLookup>
</div>
</BrowserRouter>,
)
let detail = await screen->getByText("Detail content for @as decorator.")
await element(detail)->toBeVisible
let wrapper = await screen->getByTestId("syntax-lookup-wrapper")
await element(wrapper)->toMatchScreenshot("mobile-syntax-lookup-active")
})