|
1 | 1 | import { assert, assertEquals } from "@std/assert"; |
2 | 2 | import { browserTest } from "./test_utils.ts"; |
3 | 3 |
|
4 | | -Deno.test("basic md table with dollar signs", async () => { |
| 4 | +Deno.test({ |
| 5 | + name: "basic md table with dollar signs", |
| 6 | + sanitizeResources: false, |
| 7 | + sanitizeOps: false, |
| 8 | +}, async () => { |
5 | 9 | await browserTest("basicMarkdownTable", async (page) => { |
6 | 10 | await page.waitForSelector("table", { timeout: 1000 }); |
7 | 11 | const tableExists = await page.evaluate(() => { |
@@ -78,103 +82,115 @@ Deno.test("basic md table with dollar signs", async () => { |
78 | 82 | }); |
79 | 83 | }); |
80 | 84 |
|
81 | | -Deno.test("footnote with style", async () => { |
82 | | - await browserTest("footnotes", async (page) => { |
83 | | - // 1. Test page jump on clicking footnote links |
84 | | - const scrollPositionBefore = await page.evaluate(() => globalThis.scrollY); |
85 | | - await page.click("#footnote-ref-1"); // click the first footnote link. note that we select by id, not href |
86 | | - const scrollPositionAfter = await page.evaluate(() => globalThis.scrollY); |
87 | | - assert(scrollPositionAfter > scrollPositionBefore); |
| 85 | +Deno.test( |
| 86 | + { name: "footnote with style", sanitizeResources: false, sanitizeOps: false }, |
| 87 | + async () => { |
| 88 | + await browserTest("footnotes", async (page) => { |
| 89 | + // 1. Test page jump on clicking footnote links |
| 90 | + const scrollPositionBefore = await page.evaluate(() => |
| 91 | + globalThis.scrollY |
| 92 | + ); |
| 93 | + await page.click("#footnote-ref-1"); // click the first footnote link. note that we select by id, not href |
| 94 | + const scrollPositionAfter = await page.evaluate(() => globalThis.scrollY); |
| 95 | + assert(scrollPositionAfter > scrollPositionBefore); |
88 | 96 |
|
89 | | - await page.click("#footnote-ref-bignote"); |
90 | | - const scrollPositionAfter2 = await page.evaluate(() => globalThis.scrollY); |
91 | | - assert(scrollPositionAfter2 === scrollPositionAfter); |
| 97 | + await page.click("#footnote-ref-bignote"); |
| 98 | + const scrollPositionAfter2 = await page.evaluate(() => |
| 99 | + globalThis.scrollY |
| 100 | + ); |
| 101 | + assert(scrollPositionAfter2 === scrollPositionAfter); |
92 | 102 |
|
93 | | - await page.click("#footnote-1 > p > a"); |
94 | | - const scrollPositionAfter3 = await page.evaluate(() => globalThis.scrollY); |
95 | | - assert(scrollPositionAfter3 < scrollPositionAfter2); |
96 | | - assert(scrollPositionAfter3 > scrollPositionBefore); |
| 103 | + await page.click("#footnote-1 > p > a"); |
| 104 | + const scrollPositionAfter3 = await page.evaluate(() => |
| 105 | + globalThis.scrollY |
| 106 | + ); |
| 107 | + assert(scrollPositionAfter3 < scrollPositionAfter2); |
| 108 | + assert(scrollPositionAfter3 > scrollPositionBefore); |
97 | 109 |
|
98 | | - // 2. Verify footnote link styling |
99 | | - const beforeContent = await page.evaluate(() => { |
100 | | - const element = document.querySelector("#footnote-ref-1"); |
101 | | - if (element) { |
102 | | - return globalThis.getComputedStyle(element, "::before").content; |
103 | | - } |
104 | | - return null; |
105 | | - }); |
106 | | - const afterContent = await page.evaluate(() => { |
107 | | - const element = document.querySelector("#footnote-ref-1"); |
108 | | - if (element) { |
109 | | - return globalThis.getComputedStyle(element, "::after").content; |
110 | | - } |
111 | | - return null; |
112 | | - }); |
113 | | - assertEquals(beforeContent, '"["'); |
114 | | - assertEquals(afterContent, '"]"'); |
| 110 | + // 2. Verify footnote link styling |
| 111 | + const beforeContent = await page.evaluate(() => { |
| 112 | + const element = document.querySelector("#footnote-ref-1"); |
| 113 | + if (element) { |
| 114 | + return globalThis.getComputedStyle(element, "::before").content; |
| 115 | + } |
| 116 | + return null; |
| 117 | + }); |
| 118 | + const afterContent = await page.evaluate(() => { |
| 119 | + const element = document.querySelector("#footnote-ref-1"); |
| 120 | + if (element) { |
| 121 | + return globalThis.getComputedStyle(element, "::after").content; |
| 122 | + } |
| 123 | + return null; |
| 124 | + }); |
| 125 | + assertEquals(beforeContent, '"["'); |
| 126 | + assertEquals(afterContent, '"]"'); |
115 | 127 |
|
116 | | - // 3. Check Visibility of "Footnotes" H2 |
117 | | - const h2Style = await page.evaluate(() => { |
118 | | - const element = document.querySelector("#footnote-label"); |
119 | | - if (element) { |
120 | | - const computedStyle = globalThis.getComputedStyle(element); |
121 | | - return { |
122 | | - position: computedStyle.position, |
123 | | - width: computedStyle.width, |
124 | | - height: computedStyle.height, |
125 | | - overflow: computedStyle.overflow, |
126 | | - clip: computedStyle.clip, |
127 | | - wordWrap: computedStyle.wordWrap, |
128 | | - border: computedStyle.border, |
129 | | - }; |
130 | | - } |
131 | | - return null; |
132 | | - }); |
133 | | - assert(h2Style); |
134 | | - assertEquals(h2Style.position, "absolute"); |
135 | | - assertEquals(h2Style.width, "1px"); |
136 | | - assertEquals(h2Style.height, "1px"); |
137 | | - assertEquals(h2Style.overflow, "hidden"); |
138 | | - assertEquals(h2Style.clip, "rect(0px, 0px, 0px, 0px)"); |
139 | | - assertEquals(h2Style.wordWrap, "normal"); |
140 | | - assertEquals(h2Style.border, ""); |
| 128 | + // 3. Check Visibility of "Footnotes" H2 |
| 129 | + const h2Style = await page.evaluate(() => { |
| 130 | + const element = document.querySelector("#footnote-label"); |
| 131 | + if (element) { |
| 132 | + const computedStyle = globalThis.getComputedStyle(element); |
| 133 | + return { |
| 134 | + position: computedStyle.position, |
| 135 | + width: computedStyle.width, |
| 136 | + height: computedStyle.height, |
| 137 | + overflow: computedStyle.overflow, |
| 138 | + clip: computedStyle.clip, |
| 139 | + wordWrap: computedStyle.wordWrap, |
| 140 | + border: computedStyle.border, |
| 141 | + }; |
| 142 | + } |
| 143 | + return null; |
| 144 | + }); |
| 145 | + assert(h2Style); |
| 146 | + assertEquals(h2Style.position, "absolute"); |
| 147 | + assertEquals(h2Style.width, "1px"); |
| 148 | + assertEquals(h2Style.height, "1px"); |
| 149 | + assertEquals(h2Style.overflow, "hidden"); |
| 150 | + assertEquals(h2Style.clip, "rect(0px, 0px, 0px, 0px)"); |
| 151 | + assertEquals(h2Style.wordWrap, "normal"); |
| 152 | + assertEquals(h2Style.border, ""); |
141 | 153 |
|
142 | | - // 4. Verify blue box around the footnote after clicking |
143 | | - await page.click("#footnote-ref-1"); |
144 | | - const footnoteStyle = await page.evaluate(() => { |
145 | | - const element = document.querySelector("#footnote-1"); |
146 | | - if (element) { |
147 | | - return globalThis.getComputedStyle(element) |
148 | | - .outlineColor; |
149 | | - } |
150 | | - return null; |
| 154 | + // 4. Verify blue box around the footnote after clicking |
| 155 | + await page.click("#footnote-ref-1"); |
| 156 | + const footnoteStyle = await page.evaluate(() => { |
| 157 | + const element = document.querySelector("#footnote-1"); |
| 158 | + if (element) { |
| 159 | + return globalThis.getComputedStyle(element) |
| 160 | + .outlineColor; |
| 161 | + } |
| 162 | + return null; |
| 163 | + }); |
| 164 | + assertEquals(footnoteStyle, "rgb(31, 35, 40)"); |
151 | 165 | }); |
152 | | - assertEquals(footnoteStyle, "rgb(31, 35, 40)"); |
153 | | - }); |
154 | | -}); |
| 166 | + }, |
| 167 | +); |
155 | 168 |
|
156 | | -Deno.test("yaml style", async () => { |
157 | | - await browserTest("yaml", async (page) => { |
158 | | - const nameStyle = await page.evaluate(() => { |
159 | | - const element = document.querySelector( |
160 | | - "body > main > div > pre > span:nth-child(1)", // doe in the first line |
161 | | - ); |
162 | | - if (element) { |
163 | | - return globalThis.getComputedStyle(element).color; |
164 | | - } |
165 | | - return null; |
166 | | - }); |
167 | | - assertEquals(nameStyle, "rgb(207, 34, 46)"); |
| 169 | +Deno.test( |
| 170 | + { name: "yaml style", sanitizeResources: false, sanitizeOps: false }, |
| 171 | + async () => { |
| 172 | + await browserTest("yaml", async (page) => { |
| 173 | + const nameStyle = await page.evaluate(() => { |
| 174 | + const element = document.querySelector( |
| 175 | + "body > main > div > pre > span:nth-child(1)", // doe in the first line |
| 176 | + ); |
| 177 | + if (element) { |
| 178 | + return globalThis.getComputedStyle(element).color; |
| 179 | + } |
| 180 | + return null; |
| 181 | + }); |
| 182 | + assertEquals(nameStyle, "rgb(207, 34, 46)"); |
168 | 183 |
|
169 | | - const colonStyle = await page.evaluate(() => { |
170 | | - const element = document.querySelector( |
171 | | - "body > main > div > pre > span:nth-child(2)", // : in the first line |
172 | | - ); |
173 | | - if (element) { |
174 | | - return globalThis.getComputedStyle(element).color; |
175 | | - } |
176 | | - return null; |
| 184 | + const colonStyle = await page.evaluate(() => { |
| 185 | + const element = document.querySelector( |
| 186 | + "body > main > div > pre > span:nth-child(2)", // : in the first line |
| 187 | + ); |
| 188 | + if (element) { |
| 189 | + return globalThis.getComputedStyle(element).color; |
| 190 | + } |
| 191 | + return null; |
| 192 | + }); |
| 193 | + assertEquals(colonStyle, "rgb(102, 57, 186)"); |
177 | 194 | }); |
178 | | - assertEquals(colonStyle, "rgb(102, 57, 186)"); |
179 | | - }); |
180 | | -}); |
| 195 | + }, |
| 196 | +); |
0 commit comments