GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Completed
Branch master (5d2753)
by Benjamin
17:29 queued 13:40
created

test/reducers/components/plugins/errorhandler.test.js   A

Complexity

Total Complexity 5
Complexity/F 1

Size

Lines of Code 97
Function Count 5

Duplication

Duplicated Lines 97
Ratio 100 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 0
wmc 5
c 1
b 0
f 0
nc 1
mnd 0
bc 4
fnc 5
dl 97
loc 97
rs 10
bpm 0.8
cpm 1
noi 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
/* eslint-enable describe it */
2
import expect from 'expect';
3
import { fromJS } from 'immutable';
4
5
import {
6
    ERROR_OCCURRED,
7
    DISMISS_ERROR
8
} from './../../../../src/constants/ActionTypes';
9
10
import
11
    errorhandler
12
from './../../../../src/reducers/components/plugins/errorhandler';
13
14
import {
15
    generateLastUpdate,
16
    resetLastUpdate
17
} from './../../../../src/util/lastUpdate';
18
19
describe('The errorhandler reducer', () => {
20
    beforeEach(() => resetLastUpdate());
21
22
    it('Should set an error if state was blank', () => {
23
24
        const state = fromJS({});
25
26
        const action = {
27
            type: ERROR_OCCURRED,
28
            error: 'A generic error occurred dude',
29
            stateKey: 'test-grid'
30
        };
31
32
        expect(
33
            errorhandler(state, action)
34
        ).toEqualImmutable(fromJS({
35
            'test-grid': {
36
                error: 'A generic error occurred dude',
37
                errorOccurred: true,
38
                lastUpdate: 1
39
            }
40
        }));
41
42
    });
43
44
    it('Should set an error if state was had an earlier error', () => {
45
46
        const state = fromJS({
47
            'test-grid': {
48
                error: 'A generic error occurred dude',
49
                errorOccurred: true
50
            }
51
        });
52
53
        const action = {
54
            type: ERROR_OCCURRED,
55
            error: 'A newer error happened',
56
            stateKey: 'test-grid'
57
        };
58
59
        expect(
60
            errorhandler(state, action)
61
        ).toEqualImmutable(fromJS({
62
            'test-grid': {
63
                error: 'A newer error happened',
64
                errorOccurred: true,
65
                lastUpdate: 1
66
            }
67
        }));
68
69
    });
70
71
    it('Should wipe an error if state was had an earlier error', () => {
72
73
        const state = fromJS({
74
            'test-grid': {
75
                error: 'A generic error occurred dude',
76
                errorOccurred: true,
77
                lastUpdate: 1
78
            }
79
        });
80
81
        const action = {
82
            type: DISMISS_ERROR,
83
            stateKey: 'test-grid'
84
        };
85
86
        expect(
87
            errorhandler(state, action)
88
        ).toEqualImmutable(fromJS({
89
            'test-grid': {
90
                error: '',
91
                errorOccurred: false,
92
                lastUpdate: 1
93
            }
94
        }));
95
96
    });
97
98
});
99