1
0
mirror of synced 2025-12-23 03:44:00 -05:00
Files
docs/tests/rendering/search.js
Grace Park ef2efb0636 Feature Branch: Global Nav Phase 1 (#33465)
Co-authored-by: Robert Sese <734194+rsese@users.noreply.github.com>
Co-authored-by: Joe Oak <41307427+joeoak@users.noreply.github.com>
Co-authored-by: Peter Bengtsson <peterbe@github.com>
2023-01-31 17:49:50 +00:00

31 lines
1.2 KiB
JavaScript

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"/)
})
})