| @@ 1-74 (lines=74) @@ | ||
| 1 | 'use strict'; |
|
| 2 | ||
| 3 | var test = require( 'tape' ), |
|
| 4 | actions = require( '../lib/actions' ); |
|
| 5 | ||
| 6 | test( 'newAddPageAction returns action object', function ( t ) { |
|
| 7 | var expectedAction = { |
|
| 8 | type: 'ADD_PAGE', |
|
| 9 | payload: { name: 'firstPage' } |
|
| 10 | }; |
|
| 11 | t.deepEqual( actions.newAddPageAction( 'firstPage' ), expectedAction ); |
|
| 12 | t.end(); |
|
| 13 | } ); |
|
| 14 | ||
| 15 | test( 'newNextPageAction returns action object', function ( t ) { |
|
| 16 | var expectedAction = { |
|
| 17 | type: 'NEXT_PAGE' |
|
| 18 | }; |
|
| 19 | t.deepEqual( actions.newNextPageAction(), expectedAction ); |
|
| 20 | t.end(); |
|
| 21 | } ); |
|
| 22 | ||
| 23 | test( 'newPreviousPageAction returns action object', function ( t ) { |
|
| 24 | var expectedAction = { |
|
| 25 | type: 'PREVIOUS_PAGE' |
|
| 26 | }; |
|
| 27 | t.deepEqual( actions.newPreviousPageAction(), expectedAction ); |
|
| 28 | t.end(); |
|
| 29 | } ); |
|
| 30 | ||
| 31 | test( 'newFinishPaymentDataValidationAction returns action object', function ( t ) { |
|
| 32 | var expectedAction = { |
|
| 33 | type: 'FINISH_PAYMENT_DATA_VALIDATION', |
|
| 34 | payload: { status: 'OK' } |
|
| 35 | }; |
|
| 36 | t.deepEqual( actions.newFinishPaymentDataValidationAction( { status: 'OK' } ), expectedAction ); |
|
| 37 | t.end(); |
|
| 38 | } ); |
|
| 39 | ||
| 40 | test( 'newSelectAmountAction returns action object', function ( t ) { |
|
| 41 | var expectedAction = { |
|
| 42 | type: 'SELECT_AMOUNT', |
|
| 43 | payload: { amount: '1,99' } |
|
| 44 | }; |
|
| 45 | t.deepEqual( actions.newSelectAmountAction( '1,99' ), expectedAction ); |
|
| 46 | t.end(); |
|
| 47 | } ); |
|
| 48 | ||
| 49 | test( 'newInputAmountAction returns action object', function ( t ) { |
|
| 50 | var expectedAction = { |
|
| 51 | type: 'INPUT_AMOUNT', |
|
| 52 | payload: { amount: '1,99' } |
|
| 53 | }; |
|
| 54 | t.deepEqual( actions.newInputAmountAction( '1,99' ), expectedAction ); |
|
| 55 | t.end(); |
|
| 56 | } ); |
|
| 57 | ||
| 58 | test( 'newChangeContentAction returns action object', function ( t ) { |
|
| 59 | var expectedAction = { |
|
| 60 | type: 'CHANGE_CONTENT', |
|
| 61 | payload: { contentName: 'email', value: '[email protected]' } |
|
| 62 | }; |
|
| 63 | t.deepEqual( actions.newChangeContentAction( 'email', '[email protected]' ), expectedAction ); |
|
| 64 | t.end(); |
|
| 65 | } ); |
|
| 66 | ||
| 67 | test( 'newInitializeContentAction returns action object', function ( t ) { |
|
| 68 | var expectedAction = { |
|
| 69 | type: 'INITIALIZE_CONTENT', |
|
| 70 | payload: { paymentType: 'BEZ', amount: '50,00' } |
|
| 71 | }; |
|
| 72 | t.deepEqual( actions.newInitializeContentAction( { paymentType: 'BEZ', amount: '50,00' } ), expectedAction ); |
|
| 73 | t.end(); |
|
| 74 | } ); |
|
| 75 | ||
| 76 | ||
| @@ 1-103 (lines=103) @@ | ||
| 1 | 'use strict'; |
|
| 2 | ||
| 3 | var test = require( 'tape-catch' ), |
|
| 4 | actions = require( '../lib/actions' ); |
|
| 5 | ||
| 6 | test( 'newAddPageAction returns action object', function ( t ) { |
|
| 7 | var expectedAction = { |
|
| 8 | type: 'ADD_PAGE', |
|
| 9 | payload: { name: 'firstPage' } |
|
| 10 | }; |
|
| 11 | t.deepEqual( actions.newAddPageAction( 'firstPage' ), expectedAction ); |
|
| 12 | t.end(); |
|
| 13 | } ); |
|
| 14 | ||
| 15 | test( 'newNextPageAction returns action object', function ( t ) { |
|
| 16 | var expectedAction = { |
|
| 17 | type: 'NEXT_PAGE' |
|
| 18 | }; |
|
| 19 | t.deepEqual( actions.newNextPageAction(), expectedAction ); |
|
| 20 | t.end(); |
|
| 21 | } ); |
|
| 22 | ||
| 23 | test( 'newPreviousPageAction returns action object', function ( t ) { |
|
| 24 | var expectedAction = { |
|
| 25 | type: 'PREVIOUS_PAGE' |
|
| 26 | }; |
|
| 27 | t.deepEqual( actions.newPreviousPageAction(), expectedAction ); |
|
| 28 | t.end(); |
|
| 29 | } ); |
|
| 30 | ||
| 31 | test( 'newFinishPaymentDataValidationAction returns action object', function ( t ) { |
|
| 32 | var expectedAction = { |
|
| 33 | type: 'FINISH_PAYMENT_DATA_VALIDATION', |
|
| 34 | payload: { status: 'OK' } |
|
| 35 | }; |
|
| 36 | t.deepEqual( actions.newFinishPaymentDataValidationAction( { status: 'OK' } ), expectedAction ); |
|
| 37 | t.end(); |
|
| 38 | } ); |
|
| 39 | ||
| 40 | test( 'newSelectAmountAction returns action object', function ( t ) { |
|
| 41 | var expectedAction = { |
|
| 42 | type: 'SELECT_AMOUNT', |
|
| 43 | payload: { amount: '1,99' } |
|
| 44 | }; |
|
| 45 | t.deepEqual( actions.newSelectAmountAction( '1,99' ), expectedAction ); |
|
| 46 | t.end(); |
|
| 47 | } ); |
|
| 48 | ||
| 49 | test( 'newInputAmountAction returns action object', function ( t ) { |
|
| 50 | var expectedAction = { |
|
| 51 | type: 'INPUT_AMOUNT', |
|
| 52 | payload: { amount: '1,99' } |
|
| 53 | }; |
|
| 54 | t.deepEqual( actions.newInputAmountAction( '1,99' ), expectedAction ); |
|
| 55 | t.end(); |
|
| 56 | } ); |
|
| 57 | ||
| 58 | test( 'newChangeContentAction returns action object', function ( t ) { |
|
| 59 | var expectedAction = { |
|
| 60 | type: 'CHANGE_CONTENT', |
|
| 61 | payload: { contentName: 'email', value: '[email protected]' } |
|
| 62 | }; |
|
| 63 | t.deepEqual( actions.newChangeContentAction( 'email', '[email protected]' ), expectedAction ); |
|
| 64 | t.end(); |
|
| 65 | } ); |
|
| 66 | ||
| 67 | test( 'newInitializeContentAction returns action object', function ( t ) { |
|
| 68 | var expectedAction = { |
|
| 69 | type: 'INITIALIZE_CONTENT', |
|
| 70 | payload: { paymentType: 'BEZ', amount: '50,00' } |
|
| 71 | }; |
|
| 72 | t.deepEqual( actions.newInitializeContentAction( { paymentType: 'BEZ', amount: '50,00' } ), expectedAction ); |
|
| 73 | t.end(); |
|
| 74 | } ); |
|
| 75 | ||
| 76 | ||
| 77 | test( 'newValidateInputAction returns action object', function ( t ) { |
|
| 78 | var expectedAction = { |
|
| 79 | type: 'VALIDATE_INPUT', |
|
| 80 | payload: { |
|
| 81 | contentName: 'email', |
|
| 82 | value: '[email protected]', |
|
| 83 | pattern: '^[^@]+@[^@]+$', |
|
| 84 | optionalField: false |
|
| 85 | } |
|
| 86 | }; |
|
| 87 | t.deepEqual( actions.newValidateInputAction( 'email', '[email protected]', '^[^@]+@[^@]+$' ), expectedAction ); |
|
| 88 | t.end(); |
|
| 89 | } ); |
|
| 90 | ||
| 91 | test( 'newValidateInputAction can make validation optional', function ( t ) { |
|
| 92 | var expectedAction = { |
|
| 93 | type: 'VALIDATE_INPUT', |
|
| 94 | payload: { |
|
| 95 | contentName: 'email', |
|
| 96 | value: '[email protected]', |
|
| 97 | pattern: '^[^@]+@[^@]+$', |
|
| 98 | optionalField: true |
|
| 99 | } |
|
| 100 | }; |
|
| 101 | t.deepEqual( actions.newValidateInputAction( 'email', '[email protected]', '^[^@]+@[^@]+$', true ), expectedAction ); |
|
| 102 | t.end(); |
|
| 103 | } ); |
|
| 104 | ||