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

skins/cat17/src/app/tests/state_aggregation/donation/test_salutation_validation.js   A

Complexity

Total Complexity 4
Complexity/F 1

Size

Lines of Code 68
Function Count 4

Duplication

Duplicated Lines 68
Ratio 100 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 0
wmc 4
nc 1
mnd 0
bc 4
fnc 4
dl 68
loc 68
rs 10
bpm 1
cpm 1
noi 0
c 1
b 0
f 0

4 Functions

Rating   Name   Duplication   Size   Complexity  
A test_salutation_validation.js ➔ test(ꞌSalutation is undetermined when no names are given for private addressꞌ) 16 16 1
A test_salutation_validation.js ➔ test(ꞌSalutation is valid when salutation is givenꞌ) 13 13 1
A test_salutation_validation.js ➔ test(ꞌSalutation is invalid when names are given for private address and salutation is emptyꞌ) 16 16 1
A test_salutation_validation.js ➔ test(ꞌSalutation is undetermined for non-private addressꞌ) 14 14 1

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

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
} );