Completed
Push — master ( f00ccc...4f9f1a )
by Jeroen De
56:57 queued 22:00
created

ecurring, warning is shownꞌ)   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 13

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
nc 1
nop 1
dl 0
loc 13
rs 9.4285
c 1
b 0
f 0
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