diff --git a/test/unit/reducers/alerts-reducer.test.js b/test/unit/reducers/alerts-reducer.test.js index 98e431be8a7b93910862c174f38c1448e25aee24..0ebe41875a017b7d338499e76202dae2dd86b5a6 100644 --- a/test/unit/reducers/alerts-reducer.test.js +++ b/test/unit/reducers/alerts-reducer.test.js @@ -5,6 +5,8 @@ import {AlertTypes, AlertLevels} from '../../../src/lib/alerts/index.jsx'; import alertsReducer from '../../../src/reducers/alerts'; import { closeAlert, + filterInlineAlerts, + filterPopupAlerts, showStandardAlert } from '../../../src/reducers/alerts'; @@ -123,3 +125,54 @@ test('several related alerts can be cleared at once', () => { expect(resultState.alertsList.length).toBe(1); expect(resultState.alertsList[0].alertId).toBe('createSuccess'); }); + +test('filterInlineAlerts only returns inline type alerts', () => { + const alerts = [ + { + alertId: 'extension', + alertType: AlertTypes.EXTENSION + }, + { + alertId: 'inline', + alertType: AlertTypes.INLINE + }, + { + alertId: 'standard', + alertType: AlertTypes.STANDARD + }, + { + alertId: 'non-existent type', + alertType: 'wirly-burly' + } + ]; + + const filtered = filterInlineAlerts(alerts); + expect(filtered.length).toEqual(1); + expect(filtered[0].alertId).toEqual('inline'); +}); + +test('filterPopupAlerts returns standard and extension type alerts', () => { + const alerts = [ + { + alertId: 'extension', + alertType: AlertTypes.EXTENSION + }, + { + alertId: 'inline', + alertType: AlertTypes.INLINE + }, + { + alertId: 'standard', + alertType: AlertTypes.STANDARD + }, + { + alertId: 'non-existent type', + alertType: 'wirly-burly' + } + ]; + + const filtered = filterPopupAlerts(alerts); + expect(filtered.length).toEqual(2); + expect(filtered[0].alertId).toEqual('extension'); + expect(filtered[1].alertId).toEqual('standard'); +});