forked from github/docs
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathannotations.js
More file actions
51 lines (47 loc) · 2.36 KB
/
annotations.js
File metadata and controls
51 lines (47 loc) · 2.36 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
import { getDOM } from '#src/tests/helpers/e2etest.js'
describe('annotations', () => {
test('code-snippet-with-hashbang', async () => {
const $ = await getDOM('/get-started/foo/code-snippet-with-hashbang')
const annotations = $('#article-contents .annotate')
// Check http://localhost:4000/en/get-started/foo/code-snippet-with-hashbang
// to understand the confidence in the assertions.
// This fixture page has 2 bash annotations and 1 yaml
expect(annotations.length).toBe(2 + 1)
// First code snippet block
{
const annotation = annotations.eq(0)
expect(annotation.find('.annotate-header').length).toBe(1)
expect(annotation.find('.annotate-beside').length).toBe(1)
expect(annotation.find('.annotate-inline').length).toBe(1)
expect(annotation.find('.annotate-row').length).toBe(3)
const notes = $('.annotate-row .annotate-note p', annotation)
const noteTexts = notes.map((i, el) => $(el).text()).get()
expect(noteTexts).toEqual(["Let's get started", 'This is just a sample', 'End of the script'])
}
// Second code snippet block
{
const annotation = annotations.eq(1)
expect(annotation.find('.annotate-header').length).toBe(1)
expect(annotation.find('.annotate-beside').length).toBe(1)
expect(annotation.find('.annotate-inline').length).toBe(1)
expect(annotation.find('.annotate-row').length).toBe(2)
const notes = $('.annotate-row .annotate-note p', annotation)
const noteTexts = notes.map((i, el) => $(el).text()).get()
expect(noteTexts).toEqual(['Has to start with a comment.', 'This is the if statement'])
}
// Yaml code snippet that starts with an empty comment
{
const annotation = annotations.eq(2)
expect(annotation.find('.annotate-header').length).toBe(1)
expect(annotation.find('.annotate-beside').length).toBe(1)
expect(annotation.find('.annotate-inline').length).toBe(1)
expect(annotation.find('.annotate-row').length).toBe(3)
const notes = $('.annotate-row .annotate-note p', annotation)
const noteTexts = notes.map((i, el) => $(el).text()).get()
expect(noteTexts).toEqual([
'Configures this workflow to run every time a change is pushed to the branch called release.',
'This job checks out the repository contents ...\n' + "And here's the second comment line.",
])
}
})
})