-
Notifications
You must be signed in to change notification settings - Fork 200
Expand file tree
/
Copy pathsettings-validation.test.js
More file actions
47 lines (41 loc) · 1.05 KB
/
settings-validation.test.js
File metadata and controls
47 lines (41 loc) · 1.05 KB
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
/* eslint-disable no-undef */
const Settings = require('../../../lib/settings')
jest.mock('../../../lib/env', () => ({
VALIDATE_CONFIG_SCHEMA: true,
CONFIG_PATH: '.github',
SETTINGS_FILE_PATH: 'settings.yml'
}))
const context = {
log: {
debug: jest.fn(),
info: jest.fn(),
error: jest.fn()
},
payload: {
installation: {
id: 123
}
}
}
describe('Settings Validation Tests', () => {
it('should validate config schema when VALIDATE_CONFIG_SCHEMA is true', async () => {
const settings = new Settings(true, context, {}, {
repositories: {
has_wiki: 'nonsense'
}
}, 'main', 'github')
expect(settings.results).toContainEqual(expect.objectContaining({
action: {
msg: expect.stringContaining('has_wiki must be boolean')
}
}))
})
it('should pass valid config', async () => {
const settings = new Settings(false, context, {}, {
repositories: {
has_wiki: true
}
}, 'main', 'github')
expect(settings.results).toEqual([])
})
}) // Settings Tests