This repository has been archived on 2022-08-14. You can view files and clone it, but cannot push or open issues or pull requests.
outline/app/stores/UiStore.test.js

29 lines
726 B
JavaScript
Raw Normal View History

2018-05-31 18:42:39 +00:00
/* eslint-disable */
2018-06-01 04:01:06 +00:00
import stores from '.';
2018-05-31 18:42:39 +00:00
// Actions
describe('UiStore', () => {
let store;
beforeEach(() => {
2018-06-01 04:27:18 +00:00
store = stores.ui;
2018-05-31 18:42:39 +00:00
});
2019-01-10 06:59:39 +00:00
test('#add should add messages', () => {
expect(store.orderedToasts.length).toBe(0);
2018-05-31 18:42:39 +00:00
store.showToast('first error');
store.showToast('second error');
2019-01-10 06:59:39 +00:00
expect(store.orderedToasts.length).toBe(2);
2018-05-31 18:42:39 +00:00
});
2019-01-10 06:59:39 +00:00
test('#remove should remove messages', () => {
store.toasts.clear();
const id = store.showToast('first error');
2018-05-31 18:42:39 +00:00
store.showToast('second error');
2019-01-10 06:59:39 +00:00
expect(store.orderedToasts.length).toBe(2);
store.removeToast(id);
expect(store.orderedToasts.length).toBe(1);
expect(store.orderedToasts[0].message).toBe('second error');
2018-05-31 18:42:39 +00:00
});
});