Add integration tests for questActivity webhook

This commit is contained in:
Carl Vuorinen
2020-01-10 20:58:21 +02:00
parent e6edaca11d
commit 04180fe974

View File

@@ -226,6 +226,69 @@ describe('POST /user/webhook', () => {
});
});
it('defaults questActivity options', async () => {
body.type = 'questActivity';
const webhook = await user.post('/user/webhook', body);
expect(webhook.options).to.eql({
questStarted: false,
questFinished: false,
questInvited: false,
});
});
it('can set questActivity options', async () => {
body.type = 'questActivity';
body.options = {
questStarted: true,
questFinished: true,
questInvited: true,
};
const webhook = await user.post('/user/webhook', body);
expect(webhook.options).to.eql({
questStarted: true,
questFinished: true,
questInvited: true,
});
});
it('discards extra properties in questActivity options', async () => {
body.type = 'questActivity';
body.options = {
questStarted: false,
questFinished: true,
questInvited: true,
foo: 'bar',
};
const webhook = await user.post('/user/webhook', body);
expect(webhook.options.foo).to.not.exist;
expect(webhook.options).to.eql({
questStarted: false,
questFinished: true,
questInvited: true,
});
});
['questStarted', 'questFinished', 'questInvited'].forEach(option => {
it(`requires questActivity option ${option} to be a boolean`, async () => {
body.type = 'questActivity';
body.options = {
[option]: 'not a boolean',
};
await expect(user.post('/user/webhook', body)).to.eventually.be.rejected.and.eql({
code: 400,
error: 'BadRequest',
message: t('webhookBooleanOption', { option }),
});
});
});
it('discards extra properties in globalActivity options', async () => {
body.type = 'globalActivity';
body.options = {