mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
27 lines
733 B
TypeScript
27 lines
733 B
TypeScript
import { ViewStore } from './ViewStore';
|
|
import { toJS } from 'mobx';
|
|
|
|
describe('ViewStore', () => {
|
|
let store;
|
|
|
|
beforeAll(() => {
|
|
store = ViewStore.create({
|
|
path: '',
|
|
query: {},
|
|
});
|
|
});
|
|
|
|
it('Can update path and query', () => {
|
|
store.updatePathAndQuery('/hello', { key: 1, otherParam: 'asd' });
|
|
expect(store.path).toBe('/hello');
|
|
expect(store.query.get('key')).toBe(1);
|
|
expect(store.currentUrl).toBe('/hello?key=1&otherParam=asd');
|
|
});
|
|
|
|
it('Query can contain arrays', () => {
|
|
store.updatePathAndQuery('/hello', { values: ['A', 'B'] });
|
|
expect(store.query.get('values').toJS()).toMatchObject(['A', 'B']);
|
|
expect(store.currentUrl).toBe('/hello?values=A&values=B');
|
|
});
|
|
});
|