Completed
Push — master ( 49faad...db4077 )
by wiese
63:12
created

skins/cat17/src/app/tests/test_actions.js   A

Complexity

Total Complexity 10
Complexity/F 1

Size

Lines of Code 103
Function Count 10

Duplication

Duplicated Lines 103
Ratio 100 %

Importance

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

10 Functions

Rating   Name   Duplication   Size   Complexity  
A test_actions.js ➔ test(ꞌnewPreviousPageAction returns action objectꞌ) 7 7 1
A test_actions.js ➔ test(ꞌnewInitializeContentAction returns action objectꞌ) 8 8 1
A test_actions.js ➔ test(ꞌnewSelectAmountAction returns action objectꞌ) 8 8 1
A test_actions.js ➔ test(ꞌnewAddPageAction returns action objectꞌ) 8 8 1
A test_actions.js ➔ test(ꞌnewFinishPaymentDataValidationAction returns action objectꞌ) 8 8 1
A test_actions.js ➔ test(ꞌnewInputAmountAction returns action objectꞌ) 8 8 1
A test_actions.js ➔ test(ꞌnewNextPageAction returns action objectꞌ) 7 7 1
A test_actions.js ➔ test(ꞌnewChangeContentAction returns action objectꞌ) 8 8 1
A test_actions.js ➔ test(ꞌnewValidateInputAction can make validation optionalꞌ) 13 13 1
A test_actions.js ➔ test(ꞌnewValidateInputAction returns action objectꞌ) 13 13 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
	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