Skip to content

Commit

Permalink
test: refactor metadata tests to test multi matches easier (#46746)
Browse files Browse the repository at this point in the history
Use some utils to match multiple dom nodes together

#### Match multiple props for single DOM node
```tsx
const matchDom = createDomMatcher(browser)
await matchDom('meta', 'name="description"', { content: 'description' })
```

#### Match multiple same pattern DOM nodes in html
```tsx
const $ = await next.render$('html')
const matchHtml = createHtmlMatcher($)
await matchHtml('meta', 'name', 'property', {
  description: 'description',
  og: 'og:description'
})
```

#### Match same pattern DOM nodes in browser after hydration
```tsx
const matchMultiDom = createMultiDomMatcher(browser)
  await matchMultiDom('meta', 'property', 'content', {
  description: 'description',
  'og:title': 'title',
  'twitter:title': 'title'
})
```
  • Loading branch information
huozhi authored Mar 4, 2023
1 parent 5aa9bc8 commit 9a768d5
Showing 1 changed file with 280 additions and 328 deletions.
Loading

0 comments on commit 9a768d5

Please sign in to comment.