mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-25 03:44:29 +03:00
b3bf19e9e3
refsf48892028d
refs33da584161
- There was another mather added recently: anyDateWithTimezoneOffset. The naming of date-related matchers was getting long and confusing. Renamed existing date matcher to better reflect what they do and they types of matches they are responsible for, following renames have been done: - anyShortDate -> anyISODate - anyDate -> anyISODateTime - anyDateWithTimezoneOffset -> anyISODateTimeWithTZ
95 lines
2.2 KiB
JavaScript
95 lines
2.2 KiB
JavaScript
const {
|
|
agentProvider,
|
|
fixtureManager,
|
|
mockManager,
|
|
matchers
|
|
} = 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.mockLabsEnabled('multipleProducts');
|
|
});
|
|
|
|
afterEach(function () {
|
|
mockManager.restore();
|
|
});
|
|
|
|
it('Can browse Tiers', async function () {
|
|
await agent
|
|
.get('/tiers/')
|
|
.expectStatus(200)
|
|
.matchBodySnapshot({
|
|
tiers: Array(2).fill({
|
|
id: matchers.anyObjectId,
|
|
created_at: matchers.anyISODateTime,
|
|
updated_at: matchers.anyISODateTime
|
|
})
|
|
});
|
|
});
|
|
|
|
it('Errors when price is non-integer', async function () {
|
|
const tier = {
|
|
name: 'Blah',
|
|
monthly_price: {
|
|
amount: 99.99
|
|
}
|
|
};
|
|
|
|
await agent
|
|
.post('/tiers/')
|
|
.body({tiers: [tier]})
|
|
.expectStatus(422)
|
|
.matchBodySnapshot({
|
|
errors: [{
|
|
id: matchers.anyUuid
|
|
}]
|
|
});
|
|
});
|
|
|
|
it('Errors when price is negative', async function () {
|
|
const tier = {
|
|
name: 'Blah',
|
|
monthly_price: {
|
|
amount: -100
|
|
}
|
|
};
|
|
|
|
await agent
|
|
.post('/tiers/')
|
|
.body({tiers: [tier]})
|
|
.expectStatus(422)
|
|
.matchBodySnapshot({
|
|
errors: [{
|
|
id: matchers.anyUuid
|
|
}]
|
|
});
|
|
});
|
|
|
|
it('Errors when price is too large', async function () {
|
|
const tier = {
|
|
name: 'Blah',
|
|
monthly_price: {
|
|
amount: Number.MAX_SAFE_INTEGER
|
|
}
|
|
};
|
|
|
|
await agent
|
|
.post('/tiers/')
|
|
.body({tiers: [tier]})
|
|
.expectStatus(422)
|
|
.matchBodySnapshot({
|
|
errors: [{
|
|
id: matchers.anyUuid
|
|
}]
|
|
});
|
|
});
|
|
});
|