mirror of
https://github.com/grafana/grafana.git
synced 2025-07-30 14:32:15 +08:00

* clean up almost all of the toggle * betterer * clean up searchBarHidden and extract translations * fix remaining unit tests * remove redundant topPosition
42 lines
1.4 KiB
TypeScript
42 lines
1.4 KiB
TypeScript
import { AppChromeService } from './AppChromeService';
|
|
|
|
describe('AppChromeService', () => {
|
|
it('Ignore state updates when sectionNav and pageNav have new instance but same text, url or active child', () => {
|
|
const chromeService = new AppChromeService();
|
|
let stateChanges = 0;
|
|
|
|
chromeService.state.subscribe(() => stateChanges++);
|
|
chromeService.update({
|
|
sectionNav: { node: { text: 'hello' }, main: { text: '' } },
|
|
pageNav: { text: 'test', url: 'A' },
|
|
});
|
|
chromeService.update({
|
|
sectionNav: { node: { text: 'hello' }, main: { text: '' } },
|
|
pageNav: { text: 'test', url: 'A' },
|
|
});
|
|
|
|
expect(stateChanges).toBe(2);
|
|
|
|
// if url change we should update
|
|
chromeService.update({
|
|
sectionNav: { node: { text: 'hello' }, main: { text: '' } },
|
|
pageNav: { text: 'test', url: 'new/url' },
|
|
});
|
|
expect(stateChanges).toBe(3);
|
|
|
|
// if active child changed should update state
|
|
chromeService.update({
|
|
sectionNav: { node: { text: 'hello' }, main: { text: '' } },
|
|
pageNav: { text: 'test', url: 'A', children: [{ text: 'child', active: true }] },
|
|
});
|
|
expect(stateChanges).toBe(4);
|
|
|
|
// If active child is the same we should not update state
|
|
chromeService.update({
|
|
sectionNav: { node: { text: 'hello' }, main: { text: '' } },
|
|
pageNav: { text: 'test', url: 'A', children: [{ text: 'child', active: true }] },
|
|
});
|
|
expect(stateChanges).toBe(4);
|
|
});
|
|
});
|