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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
|
import * as getters from '~/error_tracking_settings/store/getters';
import defaultState from '~/error_tracking_settings/store/state';
import { projectList, projectWithHtmlTemplate, staleProject } from '../mock';
describe('Error Tracking Settings - Getters', () => {
let state;
beforeEach(() => {
state = defaultState();
});
describe('hasProjects', () => {
it('should reflect when no projects exist', () => {
expect(getters.hasProjects(state)).toEqual(false);
});
it('should reflect when projects exist', () => {
state.projects = projectList;
expect(getters.hasProjects(state)).toEqual(true);
});
});
describe('isProjectInvalid', () => {
const mockGetters = { hasProjects: true };
it('should show when a project is valid', () => {
state.projects = projectList;
[state.selectedProject] = projectList;
expect(getters.isProjectInvalid(state, mockGetters)).toEqual(false);
});
it('should show when a project is invalid', () => {
state.projects = projectList;
state.selectedProject = staleProject;
expect(getters.isProjectInvalid(state, mockGetters)).toEqual(true);
});
});
describe('dropdownLabel', () => {
const mockGetters = { hasProjects: false };
it('should display correctly when there are no projects available', () => {
expect(getters.dropdownLabel(state, mockGetters)).toEqual('No projects available');
});
it('should display correctly when a project is selected', () => {
[state.selectedProject] = projectList;
expect(getters.dropdownLabel(state, mockGetters)).toEqual('organizationName | slug');
});
it('should display correctly when no project is selected', () => {
state.projects = projectList;
expect(getters.dropdownLabel(state, { hasProjects: true })).toEqual('Select project');
});
});
describe('invalidProjectLabel', () => {
it('should display an error containing the project name', () => {
[state.selectedProject] = projectList;
expect(getters.invalidProjectLabel(state)).toEqual(
'Project "name" is no longer available. Select another project to continue.',
);
});
it('should properly escape the label text', () => {
state.selectedProject = projectWithHtmlTemplate;
expect(getters.invalidProjectLabel(state)).toEqual(
'Project "<strong>bold</strong>" is no longer available. Select another project to continue.',
);
});
});
describe('projectSelectionLabel', () => {
it('should show the correct message when the token is empty', () => {
expect(getters.projectSelectionLabel(state)).toEqual(
'To enable project selection, enter a valid Auth Token.',
);
});
it('should show the correct message when token exists', () => {
state.token = 'test-token';
expect(getters.projectSelectionLabel(state)).toEqual(
'Click Connect to reestablish the connection to Sentry and activate the dropdown.',
);
});
});
});
|