mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-26 12:21:36 +03:00
83aa35241a
- Can now easily mock labs flags as enabled or disabled using mockManager - Updated some bits of code that directly mocked labs - Aside: improved error thrown when things go wrong booting Ghost
68 lines
1.7 KiB
JavaScript
68 lines
1.7 KiB
JavaScript
const should = require('should');
|
|
|
|
const {agentProvider, fixtureManager, mockManager} = require('../../utils/e2e-framework');
|
|
|
|
describe('Tiers API', function () {
|
|
let agent;
|
|
|
|
before(async function () {
|
|
agent = await agentProvider.getAdminAPIAgent();
|
|
await fixtureManager.init('members');
|
|
await agent.loginAsOwner();
|
|
});
|
|
|
|
beforeEach(function () {
|
|
mockManager.mockLabsDisabled('multipleProducts');
|
|
const stripeService = require('../../../core/server/services/stripe');
|
|
stripeService.api._configured = true;
|
|
});
|
|
|
|
afterEach(function () {
|
|
mockManager.restore();
|
|
const stripeService = require('../../../core/server/services/stripe');
|
|
stripeService.api._configured = false;
|
|
});
|
|
|
|
it('Errors when price is non-integer', async function () {
|
|
const tier = {
|
|
name: 'Blah',
|
|
monthly_price: {
|
|
amount: 99.99
|
|
}
|
|
};
|
|
|
|
await agent
|
|
.post('/products/')
|
|
.body({products: [tier]})
|
|
.expectStatus(422);
|
|
});
|
|
|
|
it('Errors when price is negative', async function () {
|
|
const tier = {
|
|
name: 'Blah',
|
|
monthly_price: {
|
|
amount: -100
|
|
}
|
|
};
|
|
|
|
await agent
|
|
.post('/products/')
|
|
.body({products: [tier]})
|
|
.expectStatus(422);
|
|
});
|
|
|
|
it('Errors when price is too large', async function () {
|
|
const tier = {
|
|
name: 'Blah',
|
|
monthly_price: {
|
|
amount: Number.MAX_SAFE_INTEGER
|
|
}
|
|
};
|
|
|
|
await agent
|
|
.post('/products/')
|
|
.body({products: [tier]})
|
|
.expectStatus(422);
|
|
});
|
|
});
|