mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-18 07:07:35 +01:00
* upgrade gulp-babel * upgrade babel-eslint * upgrade eslint-friendly-formatter * start upgrading chai * start to upgrade eslint * restore skipped tests * start to upgrqde monk * fix linting and remove unused file * fix mocha notifications, and common tests * fix unit tests * start to fix initrgration tests * more integration tests fixes * upgrade monk to latest version * lint /scripts * migrations: start moving to /archive unused migrations and run eslint with --fix * lint migrations * fix more integration tests * fix test
32 lines
1.0 KiB
JavaScript
32 lines
1.0 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.calledOnce;
|
|
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.calledOnce;
|
|
expect(_.template).to.have.been.calledWith(message);
|
|
expect(stub).to.have.been.calledOnce;
|
|
expect(stub).to.have.been.calledWith(vars);
|
|
});
|
|
});
|