0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-04-01 02:41:39 -05:00

Added test coverage for is over limit check

refs https://github.com/TryGhost/Team/issues/587

- There was no test coverage for MaxLimit's errorIfIsOverLimit check. Added basic test to make sure upcoming modifications don't break existing functionality
This commit is contained in:
Naz 2021-04-01 18:10:07 +13:00
parent 3bcc4256f5
commit 5dd3752f15

View file

@ -34,6 +34,43 @@ describe('Limit Service', function () {
});
});
describe('Is over limit', function () {
it('throws if is over the limit', async function () {
const config = {
max: 3,
currentCountQuery: () => 42
};
const limit = new MaxLimit({name: 'maxy', config});
try {
await limit.errorIfIsOverLimit();
should.fail(limit, 'Should have errored');
} catch (err) {
should.exist(err);
should.exist(err.errorType);
should.equal(err.errorType, 'HostLimitError');
should.exist(err.errorDetails);
should.equal(err.errorDetails.name, 'maxy');
should.exist(err.message);
should.equal(err.message, 'This action would exceed the maxy limit on your current plan.');
}
});
it('passes if does not go over the limit', async function () {
const config = {
max: 1,
currentCountQuery: () => 1
};
const limit = new MaxLimit({name: 'maxy', config});
await limit.errorIfIsOverLimit();
});
});
describe('Would go over limit', function () {
it('throws if would go over the limit', async function () {
const config = {