From af0155910b2f2b127330d2d2af650f234652d98a Mon Sep 17 00:00:00 2001 From: Paul Kaplan <pkaplan@media.mit.edu> Date: Wed, 5 Dec 2018 10:45:39 -0500 Subject: [PATCH] Increase test coverage of alerts reducer --- test/unit/reducers/alerts-reducer.test.js | 53 +++++++++++++++++++++++ 1 file changed, 53 insertions(+) diff --git a/test/unit/reducers/alerts-reducer.test.js b/test/unit/reducers/alerts-reducer.test.js index 98e431be8..0ebe41875 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'); +}); -- GitLab