WIP Write reducer test for notifications

pull/10616/head
Alex P 2018-03-01 16:37:47 -08:00 committed by Andrew Watkins
parent 5ab61c7ab6
commit 59cd86dedb
1 changed files with 43 additions and 0 deletions

View File

@ -0,0 +1,43 @@
import reducer, {initialState} from 'src/shared/reducers/notifications'
import {
publishNotification,
dismissNotification,
dismissAllNotifications,
} from 'src/shared/actions/notifications'
const notificationID = '000'
const exampleNotification = {
id: notificationID,
type: 'success',
message: 'Hell yeah you are a real notification!',
duration: 5000,
icon: 'zap',
}
describe('fsd', () => {
it('should publish a notification', () => {
const actual = reducer(
initialState,
publishNotification(exampleNotification)
)
const expected = [...initialState, exampleNotification]
expect(actual).to.equal(expected)
})
it('should dismiss a notification', () => {
const actual = reducer(initialState, dismissNotification(notificationID))
const expected = initialState.filter(n => n.id !== notificationID)
expect(actual).to.equal(expected)
})
it('should dismiss all notifications', () => {
const actual = reducer(initialState, dismissAllNotifications())
const expected = initialState
expect(actual).to.equal(expected)
})
})