|
1 | 1 | /// <reference path="../../typings/globals/jest/index.d.ts" />
|
2 | 2 | /// <reference path="../../typings/common/global.d.ts" />
|
3 | 3 |
|
4 |
| -importreducer,{_alert}from'./index'; |
| 4 | +importreducer,{_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 | constalert={};
|
34 |
| -constaction={type:'ALERT_OPEN',payload:{ alert}}; |
| 35 | +constaction={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 | +constalert={ |
| 41 | +message:'a message', |
| 42 | +action:'NOTE', |
| 43 | +duration:1500, |
| 44 | +}; |
| 45 | +constaction={type:ALERT_OPEN,payload:{ alert}}; |
| 46 | +constexpected={ |
| 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 | +constalert={ |
| 58 | +message:'a message', |
| 59 | +action:'FAIL', |
| 60 | +duration:1500, |
| 61 | +}; |
| 62 | +constaction={type:ALERT_OPEN,payload:{ alert}}; |
| 63 | +constexpected={ |
| 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 | +constalert={ |
| 75 | +message:'a message', |
| 76 | +action:'PASS', |
| 77 | +duration:1500, |
| 78 | +}; |
| 79 | +constaction={type:ALERT_OPEN,payload:{ alert}}; |
| 80 | +constexpected={ |
| 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 | constalert={};
|
40 |
| -constaction={type:'ALERT_REPLAY',payload:{ alert}}; |
| 93 | +constaction={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 |
| -constaction={type:'ALERT_CLOSE'}; |
| 98 | +constaction={type:ALERT_CLOSE}; |
46 | 99 | constalert={open:true};
|
47 | 100 | expect(reducer(alert,action).open).toBe(false);
|
48 | 101 | });
|
|