selection.test.ts 760 B

12345678910111213141516171819
  1. import { newSearchSelection, updateSearchSelection } from './selection';
  2. describe('Search selection helper', () => {
  3. it('simple dashboard selection', () => {
  4. let sel = newSearchSelection();
  5. expect(sel.isSelected('dash', 'aaa')).toBe(false);
  6. sel = updateSearchSelection(sel, true, 'dash', ['aaa']);
  7. expect(sel.isSelected('dash', 'aaa')).toBe(true);
  8. expect(sel.isSelected('dash', '*')).toBeTruthy();
  9. expect(sel.isSelected('alert', '*')).toBeFalsy();
  10. expect(sel.isSelected('*', '*')).toBeTruthy();
  11. sel = updateSearchSelection(sel, false, 'dash', ['aaa']);
  12. expect(sel.isSelected('dash', 'aaa')).toBe(false);
  13. expect(sel.items).toMatchInlineSnapshot(`Map {}`);
  14. expect(sel.isSelected('*', '*')).toBeFalsy();
  15. });
  16. });