Skip to content

Commit dea1229

Browse files
committed
test: Add test cases for the doneEach hook
1 parent f7666ca commit dea1229

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

test/e2e/plugins.test.js

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,36 @@ test.describe('Plugins', () => {
158158
});
159159
});
160160

161+
test.describe('doneEach()', () => {
162+
test('callback after cover loads', async ({ page }) => {
163+
const consoleMessages = [];
164+
165+
page.on('console', msg => consoleMessages.push(msg.text()));
166+
167+
await docsifyInit({
168+
config: {
169+
plugins: [
170+
function (hook) {
171+
hook.doneEach(() => {
172+
const homepageTitle = document.querySelector('#homepage-title');
173+
const coverTitle = document.querySelector('#cover-title');
174+
console.log(homepageTitle?.textContent);
175+
console.log(coverTitle?.textContent);
176+
});
177+
},
178+
],
179+
},
180+
markdown: {
181+
homepage: '# Hello World :id=homepage-title',
182+
coverpage: '# Cover Page :id=cover-title',
183+
},
184+
// _logHTML: true,
185+
});
186+
187+
await expect(consoleMessages).toEqual(['Hello World', 'Cover Page']);
188+
});
189+
});
190+
161191
test.describe('route data accessible to plugins', () => {
162192
let routeData = null;
163193

0 commit comments

Comments
 (0)