diff --git a/src/ui/public/management/__tests__/section.js b/src/ui/public/management/__tests__/section.js index fc081dd1334ea..6fb3c2fc9dae2 100644 --- a/src/ui/public/management/__tests__/section.js +++ b/src/ui/public/management/__tests__/section.js @@ -58,6 +58,27 @@ describe('ManagementSection', () => { }); }); + describe('deregister', () => { + let section; + + beforeEach(() => { + section = new ManagementSection('kibana'); + section.register('about'); + }); + + it ('deregisters an existing section', () => { + section.deregister('about'); + expect(section.items).to.have.length(0); + }); + + it ('allows deregistering a section more than once', () => { + section.deregister('about'); + section.deregister('about'); + expect(section.items).to.have.length(0); + }); + + }); + describe('getSection', () => { let section; diff --git a/src/ui/public/management/section.js b/src/ui/public/management/section.js index 81da1c2eb76c9..0f91443da1398 100644 --- a/src/ui/public/management/section.js +++ b/src/ui/public/management/section.js @@ -44,6 +44,15 @@ export default class ManagementSection { return item; } + /** + * Deregisters a section + * + * @param {string} id + */ + deregister(id) { + this.items.remove(item => item.id === id); + } + /** * Determine if an id is already registered *