Register
Login
Resources
Docs Blog Datasets Glossary Case Studies Tutorials & Webinars
Product
Data Engine LLMs Platform Enterprise
Pricing Explore
Connect to our Discord channel

head.js 1.3 KB

You have to be logged in to leave a comment. Sign In
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
  1. const { getDOM } = require('../helpers/supertest')
  2. const languages = require('../../lib/languages')
  3. describe('<head>', () => {
  4. jest.setTimeout(5 * 60 * 1000)
  5. test('includes hreflangs (references to all language versions of the same page)', async () => {
  6. const $ = await getDOM('/en')
  7. const $hreflangs = $('link[rel="alternate"]')
  8. expect($hreflangs.length).toEqual(Object.keys(languages).length)
  9. expect($('link[href="https://docs.github.com/cn"]').length).toBe(1)
  10. expect($('link[href="https://docs.github.com/ja"]').length).toBe(1)
  11. expect($('link[hreflang="en"]').length).toBe(1)
  12. })
  13. test('includes page intro in `description` meta tag', async () => {
  14. const $ = await getDOM('/en/articles/about-ssh')
  15. const $description = $('meta[name="description"]')
  16. expect($description.attr('content').startsWith('Using the SSH protocol')).toBe(true)
  17. })
  18. test('renders `description` meta tag in plaintext (no HTML)', async () => {
  19. const $ = await getDOM('/en/articles/about-pull-request-merges')
  20. const $description = $('meta[name="description"]')
  21. // plain text intro
  22. expect($description.attr('content').startsWith('You can merge pull requests by retaining')).toBe(true)
  23. // HTML intro
  24. expect($('div.lead-mktg').html().startsWith('<p>You can <a href="/articles/merging-a-pull-request">merge pull requests</a>'))
  25. })
  26. })
Tip!

Press p or to see the previous file or, n or to see the next file

Comments

Loading...