mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
datatrails: detect if current trail state is bookmarked (#83283)
* fix: detect if current trail state is bookmarked
This commit is contained in:
@@ -167,7 +167,7 @@ describe('TrailStore', () => {
|
||||
});
|
||||
});
|
||||
describe('Initialize store with one bookmark trail', () => {
|
||||
beforeAll(() => {
|
||||
beforeEach(() => {
|
||||
localStorage.clear();
|
||||
localStorage.setItem(
|
||||
BOOKMARKED_TRAILS_KEY,
|
||||
@@ -225,6 +225,35 @@ describe('TrailStore', () => {
|
||||
expect(store.recent.length).toBe(1);
|
||||
});
|
||||
|
||||
it('should be able to obtain index of bookmark', () => {
|
||||
const trail = store.bookmarks[0].resolve();
|
||||
const index = store.getBookmarkIndex(trail);
|
||||
expect(index).toBe(0);
|
||||
});
|
||||
|
||||
it('index should be undefined for removed bookmarks', () => {
|
||||
const trail = store.bookmarks[0].resolve();
|
||||
store.removeBookmark(0);
|
||||
const index = store.getBookmarkIndex(trail);
|
||||
expect(index).toBe(undefined);
|
||||
});
|
||||
|
||||
it('index should be undefined for a trail that has changed since it was bookmarked', () => {
|
||||
const trail = store.bookmarks[0].resolve();
|
||||
trail.setState({ metric: 'something_completely_different' });
|
||||
const index = store.getBookmarkIndex(trail);
|
||||
expect(index).toBe(undefined);
|
||||
});
|
||||
|
||||
it('should be able to obtain index of a bookmark for a trail that changed back to bookmarked state', () => {
|
||||
const trail = store.bookmarks[0].resolve();
|
||||
const bookmarkedMetric = trail.state.metric;
|
||||
trail.setState({ metric: 'something_completely_different' });
|
||||
trail.setState({ metric: bookmarkedMetric });
|
||||
const index = store.getBookmarkIndex(trail);
|
||||
expect(index).toBe(0);
|
||||
});
|
||||
|
||||
it('should remove a bookmark', () => {
|
||||
expect(store.bookmarks.length).toBe(1);
|
||||
store.removeBookmark(0);
|
||||
|
||||
Reference in New Issue
Block a user