2024-03-11 14:59:57 +00:00
|
|
|
import { apiError } from '../../../../website/server/libs/apiError';
|
2017-03-10 13:14:42 +00:00
|
|
|
|
|
|
|
|
describe('API Messages', () => {
|
|
|
|
|
const message = 'Only public guilds support pagination.';
|
|
|
|
|
it('returns an API message', () => {
|
2018-05-04 21:00:19 +00:00
|
|
|
expect(apiError('guildsOnlyPaginate')).to.equal(message);
|
2017-03-10 13:14:42 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it('throws if the API message does not exist', () => {
|
2018-05-04 21:00:19 +00:00
|
|
|
expect(() => apiError('iDoNotExist')).to.throw;
|
2017-03-10 13:14:42 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it('clones the passed variables', () => {
|
2019-10-08 18:45:38 +00:00
|
|
|
const vars = { a: 1 };
|
2017-03-10 13:14:42 +00:00
|
|
|
sandbox.stub(_, 'clone').returns({});
|
2018-05-04 21:00:19 +00:00
|
|
|
apiError('guildsOnlyPaginate', vars);
|
2018-02-17 17:11:24 +00:00
|
|
|
expect(_.clone).to.have.been.calledOnce;
|
2017-03-10 13:14:42 +00:00
|
|
|
expect(_.clone).to.have.been.calledWith(vars);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it('pass the message through _.template', () => {
|
2019-10-08 18:45:38 +00:00
|
|
|
const vars = { a: 1 };
|
|
|
|
|
const stub = sinon.stub().returns('string');
|
2017-03-10 13:14:42 +00:00
|
|
|
sandbox.stub(_, 'template').returns(stub);
|
2018-05-04 21:00:19 +00:00
|
|
|
apiError('guildsOnlyPaginate', vars);
|
2018-02-17 17:11:24 +00:00
|
|
|
expect(_.template).to.have.been.calledOnce;
|
2017-03-10 13:14:42 +00:00
|
|
|
expect(_.template).to.have.been.calledWith(message);
|
2018-02-17 17:11:24 +00:00
|
|
|
expect(stub).to.have.been.calledOnce;
|
2017-03-10 13:14:42 +00:00
|
|
|
expect(stub).to.have.been.calledWith(vars);
|
|
|
|
|
});
|
|
|
|
|
});
|