|
1 | 1 | /// <reference path="../../typings/globals/jest/index.d.ts" />
|
2 | 2 | /// <reference path="../../typings/common/global.d.ts" />
|
3 | 3 |
|
4 |
| -import reducer, { _alert } from './index'; |
| 4 | +import reducer, { _alert, colors } from './index'; |
| 5 | +import { ALERT_OPEN, ALERT_REPLAY, ALERT_CLOSE } from './types'; |
5 | 6 |
|
6 | 7 | describe('alert reducer', () => {
|
7 | 8 |
|
@@ -31,18 +32,70 @@ describe('alert reducer', () => {
|
31 | 32 |
|
32 | 33 | it('should open the alert on ALERT_OPEN', () => {
|
33 | 34 | const alert = { };
|
34 |
| - const action = { type: 'ALERT_OPEN', payload: { alert } }; |
| 35 | + const action = { type: ALERT_OPEN, payload: { alert } }; |
35 | 36 | expect(reducer({ open: false }, action).open).toBe(true);
|
36 | 37 | });
|
37 | 38 |
|
| 39 | + it('should set the NOTE alert on ALERT_OPEN', () => { |
| 40 | + const alert = { |
| 41 | + message: 'a message', |
| 42 | + action: 'NOTE', |
| 43 | + duration: 1500, |
| 44 | + }; |
| 45 | + const action = { type: ALERT_OPEN, payload: { alert } }; |
| 46 | + const expected = { |
| 47 | + message: 'a message', |
| 48 | + action: 'NOTE', |
| 49 | + duration: 1500, |
| 50 | + open: true, |
| 51 | + color: colors.NOTE |
| 52 | + }; |
| 53 | + expect(reducer({ open: false }, action)).toEqual(expected); |
| 54 | + }); |
| 55 | + |
| 56 | + it('should set the FAIL alert on ALERT_OPEN', () => { |
| 57 | + const alert = { |
| 58 | + message: 'a message', |
| 59 | + action: 'FAIL', |
| 60 | + duration: 1500, |
| 61 | + }; |
| 62 | + const action = { type: ALERT_OPEN, payload: { alert } }; |
| 63 | + const expected = { |
| 64 | + message: 'a message', |
| 65 | + action: 'FAIL', |
| 66 | + duration: 1500, |
| 67 | + open: true, |
| 68 | + color: colors.FAIL |
| 69 | + }; |
| 70 | + expect(reducer({ open: false }, action)).toEqual(expected); |
| 71 | + }); |
| 72 | + |
| 73 | + it('should set the PASS alert on ALERT_OPEN', () => { |
| 74 | + const alert = { |
| 75 | + message: 'a message', |
| 76 | + action: 'PASS', |
| 77 | + duration: 1500, |
| 78 | + }; |
| 79 | + const action = { type: ALERT_OPEN, payload: { alert } }; |
| 80 | + const expected = { |
| 81 | + message: 'a message', |
| 82 | + action: 'PASS', |
| 83 | + duration: 1500, |
| 84 | + open: true, |
| 85 | + color: colors.PASS |
| 86 | + }; |
| 87 | + expect(reducer({ open: false }, action)).toEqual(expected); |
| 88 | + }); |
| 89 | + |
| 90 | + |
38 | 91 | it('should open the alert on ALERT_REPLAY', () => {
|
39 | 92 | const alert = { };
|
40 |
| - const action = { type: 'ALERT_REPLAY', payload: { alert } }; |
| 93 | + const action = { type: ALERT_REPLAY, payload: { alert } }; |
41 | 94 | expect(reducer({ open: false }, action).open).toBe(true);
|
42 | 95 | });
|
43 | 96 |
|
44 | 97 | it('should close the alert on ALERT_CLOSE', () => {
|
45 |
| - const action = { type: 'ALERT_CLOSE' }; |
| 98 | + const action = { type: ALERT_CLOSE }; |
46 | 99 | const alert = { open: true };
|
47 | 100 | expect(reducer(alert, action).open).toBe(false);
|
48 | 101 | });
|
|
0 commit comments