ViewStore.jest.ts 732 B

1234567891011121314151617181920212223242526
  1. import { ViewStore } from './ViewStore';
  2. import { toJS } from 'mobx';
  3. describe('ViewStore', () => {
  4. let store;
  5. beforeAll(() => {
  6. store = ViewStore.create({
  7. path: '',
  8. query: {},
  9. });
  10. });
  11. it('Can update path and query', () => {
  12. store.updatePathAndQuery('/hello', { key: 1, otherParam: 'asd' });
  13. expect(store.path).toBe('/hello');
  14. expect(store.query.get('key')).toBe(1);
  15. expect(store.currentUrl).toBe('/hello?key=1&otherParam=asd');
  16. });
  17. it('Query can contain arrays', () => {
  18. store.updatePathAndQuery('/hello', { values: ['A', 'B'] });
  19. expect(toJS(store.query.get('values'))).toMatchObject(['A', 'B']);
  20. expect(store.currentUrl).toBe('/hello?values=A&values=B');
  21. });
  22. });