Skip to content

Commit

Permalink
chore: tweak
Browse files Browse the repository at this point in the history
  • Loading branch information
pengzhanbo committed Dec 13, 2024
1 parent 236ca98 commit 7aef173
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions e2e/tests/content-hooks.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,18 +27,15 @@ test('should call content mounted hook', async ({ page }) => {
await expect(mountedLocator).toHaveText(
'mounted: /content-hooks/content.html 1',
)

// update content but mounted hook should not be called twice
await updateMarkdownContent()
await expect(mountedLocator).toHaveText(
'mounted: /content-hooks/content.html 1',
)
})

/**
* onContentChange hook should only called in development
*/
test('should call content change hook', async ({ page }) => {
const mountedLocator = page.locator(
'.markdown-content-hooks .markdown-content-mounted',
)
const changeLocator = page.locator(
'.markdown-content-hooks .markdown-content-change',
)
Expand All @@ -49,14 +46,19 @@ test('should call content change hook', async ({ page }) => {

await updateMarkdownContent()
await expect(changeLocator).toHaveText(`changedCount: ${IS_DEV ? 2 : 0}`) // 2

// update content but mounted hook should not be called twice
await expect(mountedLocator).toHaveText(
'mounted: /content-hooks/content.html 1',
)
})

test('should call content before unmount hook', async ({ page }) => {
const beforeUnmountLocator = page.locator(
'.markdown-content-hooks .markdown-content-before-unmount',
)
await page.goto('content-hooks/content.html')
await page.locator('.e2e-theme-nav a[href="/"]').click()
await page.locator('.e2e-theme-nav ul > li > a').nth(0).click()

await expect(beforeUnmountLocator).toHaveText(
'beforeUnmount: /content-hooks/content.html',
Expand Down

0 comments on commit 7aef173

Please sign in to comment.