Files
habitica/test/api/v3/unit/libs/apiMessages.js
Matteo Pagliazzi 939712ad1f api: add pagination for guilds
start adding apiMessages

add apiMessages lib with tests

use apiMessage and fix tests

fix content tests

guilds pagination: add api docs

guilds pagination: improve api docs
2017-03-13 19:46:53 +01:00

32 lines
1.1 KiB
JavaScript

import apiMessages from '../../../../../website/server/libs/apiMessages';
describe('API Messages', () => {
const message = 'Only public guilds support pagination.';
it('returns an API message', () => {
expect(apiMessages('guildsOnlyPaginate')).to.equal(message);
});
it('throws if the API message does not exist', () => {
expect(() => apiMessages('iDoNotExist')).to.throw;
});
it('clones the passed variables', () => {
let vars = {a: 1};
sandbox.stub(_, 'clone').returns({});
apiMessages('guildsOnlyPaginate', vars);
expect(_.clone).to.have.been.called.once;
expect(_.clone).to.have.been.calledWith(vars);
});
it('pass the message through _.template', () => {
let vars = {a: 1};
let stub = sinon.stub().returns('string');
sandbox.stub(_, 'template').returns(stub);
apiMessages('guildsOnlyPaginate', vars);
expect(_.template).to.have.been.called.once;
expect(_.template).to.have.been.calledWith(message);
expect(stub).to.have.been.called.once;
expect(stub).to.have.been.calledWith(vars);
});
});