( doc: Document, nameOrProperty: string, expected: string, )
| 268 | } |
| 269 | |
| 270 | export function assertMetaContent( |
| 271 | doc: Document, |
| 272 | nameOrProperty: string, |
| 273 | expected: string, |
| 274 | ) { |
| 275 | let el = doc.querySelector(`meta[name="${nameOrProperty}"]`) as |
| 276 | | HTMLMetaElement |
| 277 | | null; |
| 278 | |
| 279 | if (el === null) { |
| 280 | el = doc.querySelector(`meta[property="${nameOrProperty}"]`) as |
| 281 | | HTMLMetaElement |
| 282 | | null; |
| 283 | } |
| 284 | |
| 285 | if (el === null) { |
| 286 | // deno-lint-ignore no-console |
| 287 | console.log(prettyDom(doc)); |
| 288 | throw new Error( |
| 289 | `No <meta>-tag found with content "${expected}"`, |
| 290 | ); |
| 291 | } |
| 292 | expect(el.content).toEqual(expected); |
| 293 | } |
| 294 | |
| 295 | export async function waitForText( |
| 296 | page: Page, |
no test coverage detected