mirror of
https://gitee.com/docsifyjs/docsify.git
synced 2024-12-02 03:59:19 +08:00
fix: fix search with no content. (#1878)
This commit is contained in:
parent
9832805681
commit
9b74744299
@ -211,6 +211,7 @@ export function search(query) {
|
||||
}
|
||||
|
||||
const matchContent =
|
||||
handlePostContent &&
|
||||
'...' +
|
||||
handlePostContent
|
||||
.substring(start, end)
|
||||
|
@ -176,4 +176,24 @@ test.describe('Search Plugin Tests', () => {
|
||||
await searchFieldElm.fill('hello');
|
||||
await expect(resultsHeadingElm).toHaveText('Changelog Title');
|
||||
});
|
||||
test('search when there is no body', async ({ page }) => {
|
||||
const docsifyInitConfig = {
|
||||
markdown: {
|
||||
homepage: `
|
||||
# EmptyContent
|
||||
---
|
||||
---
|
||||
`,
|
||||
},
|
||||
scriptURLs: ['/lib/plugins/search.min.js'],
|
||||
};
|
||||
|
||||
const searchFieldElm = page.locator('input[type=search]');
|
||||
const resultsHeadingElm = page.locator('.results-panel h2');
|
||||
|
||||
await docsifyInit(docsifyInitConfig);
|
||||
|
||||
await searchFieldElm.fill('empty');
|
||||
await expect(resultsHeadingElm).toHaveText('EmptyContent');
|
||||
});
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user