forked from github/docs
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsearch.js
More file actions
30 lines (25 loc) · 1.17 KB
/
search.js
File metadata and controls
30 lines (25 loc) · 1.17 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
import { expect, jest } from '@jest/globals'
import { getDOM } from '../helpers/e2etest.js'
describe('search results page', () => {
jest.setTimeout(5 * 60 * 1000)
test('says something if no query is provided', async () => {
const $ = await getDOM('/en/search')
const $container = $('[data-testid="search-results"]')
expect($container.text()).toMatch(/Enter a search term/)
// Default is the frontmatter title of the content/search/index.md
expect($('title').text()).toMatch('Search - GitHub Docs')
})
test('says something if query is empty', async () => {
const $ = await getDOM(`/en/search?${new URLSearchParams({ query: ' ' })}`)
const $container = $('[data-testid="search-results"]')
expect($container.text()).toMatch(/Enter a search term/)
})
test('mention search term in h1', async () => {
const $ = await getDOM(`/en/search?${new URLSearchParams({ query: 'peterbe' })}`)
const $container = $('[data-testid="search-results"]')
const h1Text = $container.find('h1').text()
expect(h1Text).toMatch(/Search results for/)
expect(h1Text).toMatch(/peterbe/)
expect($('title').text()).toMatch(/Search results for "peterbe"/)
})
})