Skip to content

Commit

Permalink
Add ToC icon display if enableChaptersPlugin (#1289)
Browse files Browse the repository at this point in the history
* add ToC icon display if enableChaptersPlugin

* update tests
  • Loading branch information
dualcnhq authored Dec 19, 2023
1 parent a6beb85 commit fd083e7
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/BookNavigator/book-navigator.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ export class BookNavigator extends LitElement {
* sets exit FS button (`this.fullscreenBranding1)
* when `br.options.enableFSLogoShortcut`
*/
'chapters',
'fullscreen',
'volumes',
'search',
Expand Down Expand Up @@ -359,7 +360,6 @@ export class BookNavigator extends LitElement {
}

this.menuShortcuts.push(this.menuProviders[menuId]);

this.sortMenuShortcuts();
this.emitMenuShortcutsUpdated();
}
Expand Down
1 change: 1 addition & 0 deletions src/plugins/plugin.chapters.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ BookReader.prototype._chaptersRender = function() {
}}"
/>`,
};
shell.addMenuShortcut('chapters');
shell.updateMenuContents();
this._tocEntries.forEach((tocEntry, i) => this._chaptersRenderMarker(tocEntry, i));
};
Expand Down
11 changes: 7 additions & 4 deletions tests/jest/BookNavigator/book-navigator.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -320,10 +320,13 @@ describe('<book-navigator>', () => {
describe('Shortcuts', () => {
test('has specific order of menu shortcuts to show', () => {
const el = fixtureSync(container());
expect(el.shortcutOrder[0]).toEqual('fullscreen');
expect(el.shortcutOrder[1]).toEqual('volumes');
expect(el.shortcutOrder[2]).toEqual('search');
expect(el.shortcutOrder[3]).toEqual('bookmarks');
expect(el.shortcutOrder).toEqual([
'chapters',
'fullscreen',
'volumes',
'search',
'bookmarks'
]);
});
});

Expand Down
2 changes: 2 additions & 0 deletions tests/jest/plugins/plugin.chapters.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -157,11 +157,13 @@ describe("BRChaptersPlugin", () => {
_chaptersRenderMarker: sinon.stub(),
shell: {
menuProviders: {},
addMenuShortcut: sinon.stub(),
updateMenuContents: sinon.stub(),
}
};
BookReader.prototype._chaptersRender.call(fakeBR);
expect(fakeBR.shell.menuProviders['chapters']).toBeTruthy();
expect(fakeBR.shell.addMenuShortcut.callCount).toBe(1);
expect(fakeBR.shell.updateMenuContents.callCount).toBe(1);
expect(fakeBR._chaptersRenderMarker.callCount).toBeGreaterThan(1);
});
Expand Down

0 comments on commit fd083e7

Please sign in to comment.