6e43d4dc79
* Log all gem transactions to database * Also store hourglass transactions * Fix tests * Display transaction history in hall of heroes for admins * add tests to new API call * hide transaction settings tab for non admins * fix(lint): remove console * fix(lint): various automatic corrections * fix(transactions): use enum expected pluralizations * fix api unit tests * fix lint * fix failing test * Fix minor inconsistencies * Log all gem transactions to database * Also store hourglass transactions * Fix tests * Display transaction history in hall of heroes for admins * add tests to new API call * hide transaction settings tab for non admins * fix(lint): remove console * fix(lint): various automatic corrections * fix(transactions): use enum expected pluralizations * fix api unit tests * fix lint * Fix minor inconsistencies Co-authored-by: Sabe Jones <sabrecat@gmail.com>
39 lines
1.1 KiB
JavaScript
39 lines
1.1 KiB
JavaScript
import {
|
|
generateUser,
|
|
translate as t,
|
|
} from '../../../helpers/api-integration/v4';
|
|
|
|
describe('GET /members/:memberId/purchase-history', () => {
|
|
let user;
|
|
|
|
before(async () => {
|
|
user = await generateUser({
|
|
contributor: { admin: true },
|
|
});
|
|
});
|
|
|
|
it('validates req.params.memberId', async () => {
|
|
await expect(user.get('/members/invalidUUID/purchase-history')).to.eventually.be.rejected.and.eql({
|
|
code: 400,
|
|
error: 'BadRequest',
|
|
message: t('invalidReqParams'),
|
|
});
|
|
});
|
|
|
|
it('returns error if user is not admin', async () => {
|
|
const member = await generateUser();
|
|
const nonAdmin = await generateUser();
|
|
await expect(nonAdmin.get(`/members/${member._id}/purchase-history`)).to.eventually.be.rejected.and.eql({
|
|
code: 401,
|
|
error: 'NotAuthorized',
|
|
message: t('noAdminAccess'),
|
|
});
|
|
});
|
|
|
|
it('returns purchase history based on given user', async () => {
|
|
const member = await generateUser();
|
|
const response = await user.get(`/members/${member._id}/purchase-history`);
|
|
expect(response.length).to.equal(0);
|
|
});
|
|
});
|