mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-16 06:07:21 +01:00
* Re-organize common folder * fix: Correct paths in tests * fix: move new content to proper folder * chore: Move audio folder to assets * Move sprites to sprites assets directory * Move css sprites to assets directory * Split out readmes for common code and sprites * Move images to assets directory * Move destinatin of shared browserified file * remove unused file * move compiled js to client-old * Fix karma tests * fix: Correct paths for sprites
43 lines
1.0 KiB
JavaScript
43 lines
1.0 KiB
JavaScript
import updateWebhook from '../../../website/common/script/ops/updateWebhook';
|
|
import {
|
|
BadRequest,
|
|
} from '../../../website/common/script/libs/errors';
|
|
import i18n from '../../../website/common/script/i18n';
|
|
import {
|
|
generateUser,
|
|
} from '../../helpers/common.helper';
|
|
|
|
describe('shared.ops.updateWebhook', () => {
|
|
let user;
|
|
let req;
|
|
let newUrl = 'http://new-url.com';
|
|
|
|
beforeEach(() => {
|
|
user = generateUser();
|
|
req = { params: {
|
|
id: 'this-id',
|
|
}, body: {
|
|
url: newUrl,
|
|
enabled: true,
|
|
} };
|
|
});
|
|
|
|
it('validates body', (done) => {
|
|
delete req.body.url;
|
|
try {
|
|
updateWebhook(user, req);
|
|
} catch (err) {
|
|
expect(err).to.be.an.instanceof(BadRequest);
|
|
expect(err.message).to.equal(i18n.t('invalidUrl'));
|
|
done();
|
|
}
|
|
});
|
|
|
|
it('succeeds', () => {
|
|
let url = 'http://existing-url.com';
|
|
user.preferences.webhooks = { 'this-id': { url } };
|
|
updateWebhook(user, req);
|
|
expect(user.preferences.webhooks['this-id'].url).to.eql(newUrl);
|
|
});
|
|
});
|