-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathconstants.test.js
133 lines (114 loc) · 4.43 KB
/
constants.test.js
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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
import { jest } from '@jest/globals';
import {
GOOGLE_SHEET_ID,
GOOGLE_KEYFILE_PATH,
TEST_TYPES_AVAILABLE,
TEST_CATEGORIES_AVAILABLE,
WEEK_START,
WEEKLY_SUMMARY_ENABLED,
ALL_TEAM_NAMES,
} from './constants.js';
describe('Constants', () => {
const originalEnv = process.env;
const mockConfigDetails = {
googleSpreadsheetUrl: 'https://docs.google.com/spreadsheets/d/abc123/edit',
googleKeyFilePath: '/path/to/key.json',
testTypes: ['custom1', 'custom2'],
testCategories: ['custom1', 'custom2'],
teamNames: ['team1', 'team2'],
weeklySummaryStartDay: 'Monday',
};
beforeEach(() => {
jest.clearAllMocks();
process.env = { ...originalEnv };
global.shadowConfigDetails = mockConfigDetails;
});
afterEach(() => {
process.env = originalEnv;
global.shadowConfigDetails = undefined;
});
describe.skip('GOOGLE_SHEET_ID', () => {
it('should extract sheet ID from config URL', () => {
expect(GOOGLE_SHEET_ID()).toBe('abc123');
});
it('should handle environment variable URL', () => {
process.env.SHEET_ID =
'https://docs.google.com/spreadsheets/d/xyz789/edit';
global.shadowConfigDetails.googleSpreadsheetUrl = 'process.env.SHEET_ID';
expect(GOOGLE_SHEET_ID()).toBe('xyz789');
});
it('should return empty string when no URL is configured', () => {
global.shadowConfigDetails.googleSpreadsheetUrl = undefined;
expect(GOOGLE_SHEET_ID()).toBe('');
});
});
describe.skip('GOOGLE_KEYFILE_PATH', () => {
it('should return key file path from config', () => {
expect(GOOGLE_KEYFILE_PATH()).toBe('/path/to/key.json');
});
it('should handle environment variable path', () => {
process.env.KEY_FILE_PATH = '/env/path/key.json';
global.shadowConfigDetails.googleKeyFilePath =
'process.env.KEY_FILE_PATH';
expect(GOOGLE_KEYFILE_PATH()).toBe('/env/path/key.json');
});
it('should return empty string when no path is configured', () => {
global.shadowConfigDetails.googleKeyFilePath = undefined;
expect(GOOGLE_KEYFILE_PATH()).toBe('');
});
});
describe('TEST_TYPES_AVAILABLE', () => {
it.skip('should return custom test types when configured', () => {
expect(TEST_TYPES_AVAILABLE()).toEqual(['custom1', 'custom2']);
});
it('should return default test types when no custom types configured', () => {
global.shadowConfigDetails.testTypes = undefined;
const defaultTypes = TEST_TYPES_AVAILABLE();
expect(defaultTypes).toContain('api');
expect(defaultTypes).toContain('ui');
expect(defaultTypes).toContain('unit');
});
});
describe('TEST_CATEGORIES_AVAILABLE', () => {
it.skip('should return custom categories when configured', () => {
expect(TEST_CATEGORIES_AVAILABLE()).toEqual(['custom1', 'custom2']);
});
it('should return default categories when no custom categories configured', () => {
global.shadowConfigDetails.testCategories = undefined;
const defaultCategories = TEST_CATEGORIES_AVAILABLE();
expect(defaultCategories).toContain('smoke');
expect(defaultCategories).toContain('regression');
expect(defaultCategories).toContain('sanity');
});
});
describe('WEEK_START', () => {
it('should return configured weekly summary start day', () => {
expect(WEEK_START()).toBe('Monday');
});
it.skip('should return undefined when no start day configured', () => {
global.shadowConfigDetails.weeklySummaryStartDay = undefined;
expect(WEEK_START()).toBeUndefined();
});
});
describe('WEEKLY_SUMMARY_ENABLED', () => {
it('should return true when weekly summary is configured', () => {
expect(WEEKLY_SUMMARY_ENABLED()).toBe(true);
});
it.skip('should return false when weekly summary is not configured', () => {
global.shadowConfigDetails.weeklySummaryStartDay = undefined;
expect(WEEKLY_SUMMARY_ENABLED()).toBe(false);
});
});
describe('ALL_TEAM_NAMES', () => {
it.skip('should return custom team names when configured', () => {
expect(ALL_TEAM_NAMES()).toEqual(['team1', 'team2']);
});
it('should return default team names when no custom teams configured', () => {
global.shadowConfigDetails.teamNames = undefined;
const defaultTeams = ALL_TEAM_NAMES();
expect(defaultTeams).toContain('raptors');
expect(defaultTeams).toContain('kimchi');
expect(defaultTeams).toContain('protus');
});
});
});