forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdocblock-code-block-line-number.goml
68 lines (60 loc) · 2.09 KB
/
docblock-code-block-line-number.goml
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
// Checks that the setting "line numbers" is working as expected.
include: "utils.goml"
go-to: "file://" + |DOC_PATH| + "/test_docs/fn.foo.html"
// Otherwise, we can't check text color
show-text: true
// We check that without this setting, there is no line number displayed.
assert-false: "pre.example-line-numbers"
// Let's now check some CSS properties...
define-function: (
"check-colors",
[theme, color],
block {
// We now set the setting to show the line numbers on code examples.
set-local-storage: {"rustdoc-line-numbers": "true"}
// Page will be reloaded in "switch-theme".
call-function: ("switch-theme", {"theme": |theme|})
// We wait for the line numbers to be added into the DOM by the JS...
wait-for: "pre.example-line-numbers"
// If the test didn't fail, it means that it was found!
assert-css: (
"pre.example-line-numbers",
{
"color": |color|,
"margin": "0px",
"padding": "14px 8px",
"text-align": "right",
},
ALL,
)
},
)
call-function: ("check-colors", {
"theme": "ayu",
"color": "#5c6773",
})
call-function: ("check-colors", {
"theme": "dark",
"color": "#3b91e2",
})
call-function: ("check-colors", {
"theme": "light",
"color": "#c67e2d",
})
// The first code block has two lines so let's check its `<pre>` elements lists both of them.
assert-text: ("pre.example-line-numbers", "1\n2")
// Now, try changing the setting dynamically. We'll turn it off, using the settings menu,
// and make sure it goes away.
// First, open the settings menu.
click: "#settings-menu"
wait-for: "#settings"
assert-css: ("#settings", {"display": "block"})
// Then, click the toggle button.
click: "input#line-numbers"
wait-for: 100 // wait-for-false does not exist
assert-false: "pre.example-line-numbers"
assert-local-storage: {"rustdoc-line-numbers": "false" }
// Finally, turn it on again.
click: "input#line-numbers"
wait-for: "pre.example-line-numbers"
assert-local-storage: {"rustdoc-line-numbers": "true" }