Skip to content

Commit

Permalink
Add timeouts to highlighting tests
Browse files Browse the repository at this point in the history
  • Loading branch information
bglw committed Oct 11, 2023
1 parent 27b1294 commit 9a080c3
Showing 1 changed file with 21 additions and 5 deletions.
26 changes: 21 additions & 5 deletions pagefind/features/highlighting/highlighting_base.feature
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,11 @@ Feature: Highlighting Tests
<script type="module">
await import('/pagefind/pagefind-highlight.js');
new PagefindHighlight({
pagefindQueryParamName: 'custom-name',
markOptions: {
className: 'custom-class',
pagefindQueryParamName: 'custom-name',
markOptions: {
className: 'custom-class',
exclude: [
"[data-pagefind-ignore]",
"[data-pagefind-ignore]",
"[data-pagefind-ignore] *",
".ignore"
]
Expand All @@ -74,11 +74,19 @@ Feature: Highlighting Tests

Scenario: Highlight script is loaded
When I load "/words/"
When I evaluate:
"""
async function() { await new Promise(r => setTimeout(r, 200)); }
"""
Then I should see the file "public/pagefind/pagefind-highlight.js"
Then There should be no logs

Scenario: Highlight script marks correctly
When I load "/words/?pagefind-highlight=this"
When I evaluate:
"""
async function() { await new Promise(r => setTimeout(r, 200)); }
"""
Then There should be no logs
Then The selector "#has-highlight mark" should contain "this"
Then The selector "#has-highlight mark.pagefind-highlight" should contain "this"
Expand All @@ -101,6 +109,10 @@ Feature: Highlighting Tests

Scenario: Highlight script stays within pagefind-body
When I load "/single-body/?pagefind-highlight=this"
When I evaluate:
"""
async function() { await new Promise(r => setTimeout(r, 200)); }
"""
Then There should be no logs
Then The selector "#has-highlight mark" should contain "This"
Then The selector "p[data-pagefind-ignore]" should contain "This should not be highlighted"
Expand All @@ -113,10 +125,14 @@ Feature: Highlighting Tests

Scenario: Highlight script options work
When I load "/options/?custom-name=this"
When I evaluate:
"""
async function() { await new Promise(r => setTimeout(r, 200)); }
"""
Then There should be no logs
Then The selector "#has-highlight mark" should contain "This"
Then The selector "#has-highlight mark.custom-class" should contain "This"
Then The selector "p[data-pagefind-ignore]" should contain "This should not be highlighted"
Then The selector "p.ignore" should contain "This should not be highlighted"
Then The selector "#no-highlight" should contain "This should not be highlighted"

0 comments on commit 9a080c3

Please sign in to comment.