forked from github/docs
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcurated-homepage-links.js
More file actions
52 lines (44 loc) · 1.71 KB
/
curated-homepage-links.js
File metadata and controls
52 lines (44 loc) · 1.71 KB
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
const { getDOM } = require('../helpers/supertest')
describe('curated homepage links', () => {
jest.setTimeout(5 * 60 * 1000)
test('English', async () => {
const $ = await getDOM('/en')
const $links = $('a.link-with-intro')
expect($links.length).toBeGreaterThanOrEqual(8)
// Check that each link is localized and includes a title and intro
$links.each((i, el) => {
const linkUrl = $(el).attr('href')
expect(linkUrl.startsWith('/en/')).toBe(true)
expect(
$(el).find('.link-with-intro-title').text().trim().length,
`Did not find a title for the linked article ${linkUrl}`
).toBeGreaterThan(0)
expect(
$(el).find('.link-with-intro-intro').text().trim().length,
`Did not find an intro for the linked article ${linkUrl}`
).toBeGreaterThan(0)
// ensure there's no unwanted nested HTML
expect($(el).find('p').length).toBe(1)
expect($(el).find('a').length).toBe(0)
expect($(el).find('p p').length).toBe(0)
})
})
test('Japanese', async () => {
const $ = await getDOM('/ja')
const $links = $('a.link-with-intro')
expect($links.length).toBeGreaterThanOrEqual(8)
// Check that each link is localized and includes a title and intro
$links.each((i, el) => {
const linkUrl = $(el).attr('href')
expect(linkUrl.startsWith('/ja/')).toBe(true)
expect(
$(el).find('.link-with-intro-title').text().trim().length,
`Did not find a title for the linked article ${linkUrl}`
).toBeGreaterThan(0)
expect(
$(el).find('.link-with-intro-intro').text().trim().length,
`Did not find an intro for the linked article ${linkUrl}`
).toBeGreaterThan(0)
})
})
})