Completed
Push — master ( 7dd269...49faad )
by wiese
116:51 queued 51:49
created

ꞌ)   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 13

Duplication

Lines 13
Ratio 100 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
nc 1
dl 13
loc 13
rs 9.4285
c 1
b 0
f 0
nop 1
1 View Code Duplication
'use strict';
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
2
3
var test = require( 'tape-catch' ),
4
	salutationIsValid = require( '../../../lib/state_aggregation/donation/salutation_is_valid' )
5
;
6
7
test( 'Salutation is undetermined for non-private address', function ( t ) {
8
	var state = {
9
			donationFormContent: {
10
				addressType: 'firma',
11
				salutation: ''
12
			}
13
		},
14
		expectedValidation = {
15
			isValid: null,
16
			dataEntered: false
17
		};
18
	t.deepEqual( salutationIsValid( state ), expectedValidation );
19
	t.end();
20
} );
21
22
test( 'Salutation is undetermined when no names are given for private address', function ( t ) {
23
	var state = {
24
			donationFormContent: {
25
				addressType: 'person',
26
				firstName: '',
27
				lastName: '',
28
				salutation: ''
29
			}
30
		},
31
		expectedValidation = {
32
			isValid: null,
33
			dataEntered: false
34
		};
35
	t.deepEqual( salutationIsValid( state ), expectedValidation );
36
	t.end();
37
} );
38
39
test( 'Salutation is invalid when names are given for private address and salutation is empty', function ( t ) {
40
	var state = {
41
			donationFormContent: {
42
				addressType: 'person',
43
				firstName: 'Kylo',
44
				lastName: 'Ren',
45
				salutation: ''
46
			}
47
		},
48
		expectedValidation = {
49
			isValid: false,
50
			dataEntered: true
51
		};
52
	t.deepEqual( salutationIsValid( state ), expectedValidation );
53
	t.end();
54
} );
55
56
test( 'Salutation is valid when salutation is given', function ( t ) {
57
	var state = {
58
			donationFormContent: {
59
				salutation: 'Herr'
60
			}
61
		},
62
		expectedValidation = {
63
			isValid: true,
64
			dataEntered: true
65
		};
66
	t.deepEqual( salutationIsValid( state ), expectedValidation );
67
	t.end();
68
} );