fork/rust
git clone https://git.julia.blue/fork/rust
3bcad65fbf6
master
1// Checks that the setting "line numbers" is working as expected. 2go-to: "file://" + |DOC_PATH| + "/test_docs/fn.foo.html" 3 4// Otherwise, we can't check text color 5show-text: true 6 7// We check that without this setting, there is no line number displayed. 8assert-false: "pre.example-line-numbers" 9 10// Let's now check some CSS properties... 11define-function: ( 12 "check-colors", 13 (theme, color), 14 block { 15 // We now set the setting to show the line numbers on code examples. 16 set-local-storage: { 17 "rustdoc-theme": |theme|, 18 "rustdoc-use-system-theme": "false", 19 "rustdoc-line-numbers": "true" 20 } 21 // We reload to make the line numbers appear and change theme. 22 reload: 23 // We wait for them to be added into the DOM by the JS... 24 wait-for: "pre.example-line-numbers" 25 // If the test didn't fail, it means that it was found! 26 assert-css: ( 27 "pre.example-line-numbers", 28 { 29 "color": |color|, 30 "margin": "0px", 31 "padding": "14px 8px", 32 "text-align": "right", 33 }, 34 ALL, 35 ) 36 }, 37) 38call-function: ("check-colors", { 39 "theme": "ayu", 40 "color": "#5c6773", 41}) 42call-function: ("check-colors", { 43 "theme": "dark", 44 "color": "#3b91e2", 45}) 46call-function: ("check-colors", { 47 "theme": "light", 48 "color": "#c67e2d", 49}) 50 51// The first code block has two lines so let's check its `<pre>` elements lists both of them. 52assert-text: ("pre.example-line-numbers", "1\n2") 53 54// Now, try changing the setting dynamically. We'll turn it off, using the settings menu, 55// and make sure it goes away. 56 57// First, open the settings menu. 58click: "#settings-menu" 59wait-for: "#settings" 60assert-css: ("#settings", {"display": "block"}) 61 62// Then, click the toggle button. 63click: "input#line-numbers" 64wait-for: 100 // wait-for-false does not exist 65assert-false: "pre.example-line-numbers" 66assert-local-storage: {"rustdoc-line-numbers": "false" } 67 68// Finally, turn it on again. 69click: "input#line-numbers" 70wait-for: "pre.example-line-numbers" 71assert-local-storage: {"rustdoc-line-numbers": "true" }