Skip to content

Commit dec2296

Browse files
committed
add webhook config tests
Signed-off-by: shmck <[email protected]>
1 parent 99b3dbe commit dec2296

File tree

3 files changed

+36
-2
lines changed

3 files changed

+36
-2
lines changed

Diff for: src/schema/skeleton.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -183,9 +183,10 @@ export default {
183183
},
184184
},
185185
},
186+
additionalProperties: false,
186187
},
187-
additionalProperties: false,
188188
},
189+
required: ["url", "events"],
189190
},
190191
},
191192
additionalProperties: false,

Diff for: src/schema/tutorial.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -202,9 +202,10 @@ export default {
202202
},
203203
},
204204
},
205+
additionalProperties: false,
205206
},
206-
additionalProperties: false,
207207
},
208+
required: ["url", "events"],
208209
},
209210
},
210211
additionalProperties: false,

Diff for: tests/skeleton.test.ts

+32
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,38 @@ describe('validate skeleton', () => {
197197
const valid = validateSkeleton(json)
198198
expect(valid).toBe(false)
199199
})
200+
it('should fail if webhook url is missing', () => {
201+
const json = {
202+
...validJson,
203+
config: {
204+
...validJson.config,
205+
webhook: {
206+
events: {}
207+
}
208+
}
209+
}
210+
211+
const valid = validateSkeleton(json)
212+
expect(valid).toBe(false)
213+
})
214+
it('should fail if webhook events include non-listed events', () => {
215+
const json = {
216+
...validJson,
217+
config: {
218+
...validJson.config,
219+
webhook: {
220+
...validJson.config.webhook,
221+
events: {
222+
...validJson.config.webhook.events,
223+
not_an_event: true,
224+
}
225+
}
226+
}
227+
}
228+
229+
const valid = validateSkeleton(json)
230+
expect(valid).toBe(false)
231+
})
200232
it('should fail if level is missing id', () => {
201233
const level1 = { ...validJson.levels[0], id: undefined }
202234
const json = {

0 commit comments

Comments
 (0)