feat: add hasInvisibleChild method to routes service

pull/4445/head
Arman Ozak 5 years ago
parent 81c83d56f1
commit 51159b3693

@ -144,6 +144,11 @@ export abstract class AbstractNavTreeService<T extends ABP.Nav> extends Abstract
return this.store.selectSnapshot(ConfigState.getGrantedPolicy(requiredPolicy));
}
hasInvisibleChild(identifier: string): boolean {
const node = this.find(item => item[this.id] === identifier);
return node?.children?.some(child => child.invisible);
}
/* istanbul ignore next */
ngOnDestroy() {}
}

@ -68,6 +68,16 @@ describe('Routes Service', () => {
});
});
describe('#hasInvisibleChild', () => {
it('should return if node has invisible child', () => {
service.add(routes);
expect(service.hasInvisibleChild('foo')).toBe(true);
expect(service.hasInvisibleChild('bar')).toBe(false);
expect(service.hasInvisibleChild('baz')).toBe(false);
});
});
describe('#remove', () => {
it('should remove routes based on given routeNames', () => {
service.add(routes);

Loading…
Cancel
Save