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

curated-homepage-links.js 1.7 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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
  1. const { getDOM } = require('../helpers/supertest')
  2. describe('curated homepage links', () => {
  3. jest.setTimeout(5 * 60 * 1000)
  4. test('English', async () => {
  5. const $ = await getDOM('/en')
  6. const $links = $('a.link-with-intro')
  7. expect($links.length).toBeGreaterThanOrEqual(8)
  8. // Check that each link is localized and includes a title and intro
  9. $links.each((i, el) => {
  10. const linkUrl = $(el).attr('href')
  11. expect(linkUrl.startsWith('/en/')).toBe(true)
  12. expect(
  13. $(el).find('.link-with-intro-title').text().trim().length,
  14. `Did not find a title for the linked article ${linkUrl}`
  15. ).toBeGreaterThan(0)
  16. expect(
  17. $(el).find('.link-with-intro-intro').text().trim().length,
  18. `Did not find an intro for the linked article ${linkUrl}`
  19. ).toBeGreaterThan(0)
  20. // ensure there's no unwanted nested HTML
  21. expect($(el).find('p').length).toBe(1)
  22. expect($(el).find('a').length).toBe(0)
  23. expect($(el).find('p p').length).toBe(0)
  24. })
  25. })
  26. test('Japanese', async () => {
  27. const $ = await getDOM('/ja')
  28. const $links = $('a.link-with-intro')
  29. expect($links.length).toBeGreaterThanOrEqual(8)
  30. // Check that each link is localized and includes a title and intro
  31. $links.each((i, el) => {
  32. const linkUrl = $(el).attr('href')
  33. expect(linkUrl.startsWith('/ja/')).toBe(true)
  34. expect(
  35. $(el).find('.link-with-intro-title').text().trim().length,
  36. `Did not find a title for the linked article ${linkUrl}`
  37. ).toBeGreaterThan(0)
  38. expect(
  39. $(el).find('.link-with-intro-intro').text().trim().length,
  40. `Did not find an intro for the linked article ${linkUrl}`
  41. ).toBeGreaterThan(0)
  42. })
  43. })
  44. })
Tip!

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

Comments

Loading...