1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
|
import * as getters from '~/admin/statistics_panel/store/getters';
import createState from '~/admin/statistics_panel/store/state';
describe('Admin statistics panel getters', () => {
let state;
beforeEach(() => {
state = createState();
});
describe('getStatistics', () => {
describe('when statistics data exists', () => {
it('returns an array of statistics objects with key, label and value', () => {
state.statistics = { forks: 10, issues: 20 };
const statisticsLabels = {
forks: 'Forks',
issues: 'Issues',
};
const statisticsData = [
{ key: 'forks', label: 'Forks', value: 10 },
{ key: 'issues', label: 'Issues', value: 20 },
];
expect(getters.getStatistics(state)(statisticsLabels)).toEqual(statisticsData);
});
});
describe('when no statistics data exists', () => {
it('returns an array of statistics objects with key, label and sets value to null', () => {
state.statistics = null;
const statisticsLabels = {
forks: 'Forks',
issues: 'Issues',
};
const statisticsData = [
{ key: 'forks', label: 'Forks', value: null },
{ key: 'issues', label: 'Issues', value: null },
];
expect(getters.getStatistics(state)(statisticsLabels)).toEqual(statisticsData);
});
});
});
});
|