|
1
|
|
|
'use strict'; |
|
2
|
|
|
|
|
3
|
|
|
var test = require( 'tape' ), |
|
4
|
|
|
sinon = require( 'sinon' ), |
|
5
|
|
|
pplRecurrentWarning = require( '../../lib/view_handler/recurrent_paypal_notice' ), |
|
6
|
|
|
createPPLRecurrentWarningHandler = pplRecurrentWarning.createRecurrentPaypalNoticeHandler |
|
7
|
|
|
; |
|
8
|
|
|
|
|
9
|
|
|
function createAnimator() { |
|
10
|
|
|
return { |
|
11
|
|
|
showElement: sinon.spy(), |
|
12
|
|
|
hideElement: sinon.spy() |
|
13
|
|
|
}; |
|
14
|
|
|
} |
|
15
|
|
|
|
|
16
|
|
|
test( 'When interval is recurring, warning is shown', function ( t ) { |
|
17
|
|
|
var animator = createAnimator(), |
|
18
|
|
|
handler = createPPLRecurrentWarningHandler( animator ); |
|
19
|
|
|
|
|
20
|
|
|
handler.update( { |
|
21
|
|
|
paymentType: 'PPL', |
|
22
|
|
|
paymentIntervalInMonths: 12 |
|
23
|
|
|
} ); |
|
24
|
|
|
|
|
25
|
|
|
t.ok( animator.showElement.calledOnce, 'Element is shown' ); |
|
26
|
|
|
t.notOk( animator.hideElement.called, 'Element is not hidden' ); |
|
27
|
|
|
t.end(); |
|
28
|
|
|
} ); |
|
29
|
|
|
|
|
30
|
|
|
test( 'When interval is not recurring, warning is hidden', function ( t ) { |
|
31
|
|
|
var animator = createAnimator(), |
|
32
|
|
|
handler = createPPLRecurrentWarningHandler( animator ); |
|
33
|
|
|
|
|
34
|
|
|
handler.update( { |
|
35
|
|
|
paymentType: 'PPL', |
|
36
|
|
|
paymentIntervalInMonths: 0 |
|
37
|
|
|
} ); |
|
38
|
|
|
|
|
39
|
|
|
t.ok( animator.hideElement.calledOnce, 'Element is hidden' ); |
|
40
|
|
|
t.notOk( animator.showElement.called, 'Element is not shown' ); |
|
41
|
|
|
t.end(); |
|
42
|
|
|
} ); |
|
43
|
|
|
|
|
44
|
|
|
test( 'When payment type is paypal and interval is recurring, warning is hidden', function ( t ) { |
|
45
|
|
|
var animator = createAnimator(), |
|
46
|
|
|
handler = createPPLRecurrentWarningHandler( animator ); |
|
47
|
|
|
|
|
48
|
|
|
handler.update( { |
|
49
|
|
|
paymentType: 'BEZ', |
|
50
|
|
|
paymentIntervalInMonths: 12 |
|
51
|
|
|
} ); |
|
52
|
|
|
|
|
53
|
|
|
t.ok( animator.hideElement.calledOnce, 'Element is hidden' ); |
|
54
|
|
|
t.notOk( animator.showElement.called, 'Element is not shown' ); |
|
55
|
|
|
t.end(); |
|
56
|
|
|
} ); |
|
57
|
|
|
|
|
58
|
|
|
|