mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-18 05:40:31 +00:00
feat(nestjs): migrate to NestJS
This commit is contained in:
104
packages/server/test/manual-journal.e2e-spec.ts
Normal file
104
packages/server/test/manual-journal.e2e-spec.ts
Normal file
@@ -0,0 +1,104 @@
|
||||
import * as request from 'supertest';
|
||||
import { faker } from '@faker-js/faker';
|
||||
import { app, AuthorizationHeader, orgainzationId } from './init-app-test';
|
||||
|
||||
const makeManualJournalRequest = () => ({
|
||||
date: '2022-06-01',
|
||||
reference: faker.string.uuid(),
|
||||
journalNumber: faker.string.uuid(),
|
||||
publish: false,
|
||||
entries: [
|
||||
{
|
||||
index: 1,
|
||||
credit: 1000,
|
||||
debit: 0,
|
||||
accountId: 1003,
|
||||
},
|
||||
{
|
||||
index: 2,
|
||||
credit: 0,
|
||||
debit: 1000,
|
||||
accountId: 1004,
|
||||
},
|
||||
],
|
||||
});
|
||||
|
||||
describe.only('Manual Journals (e2e)', () => {
|
||||
it('/manual-journals (POST)', () => {
|
||||
return request(app.getHttpServer())
|
||||
.post('/manual-journals')
|
||||
.set('organization-id', orgainzationId)
|
||||
.set('Authorization', AuthorizationHeader)
|
||||
.send(makeManualJournalRequest())
|
||||
.expect(201);
|
||||
});
|
||||
|
||||
it('/manual-journals/:id (DELETE)', async () => {
|
||||
const response = await request(app.getHttpServer())
|
||||
.post('/manual-journals')
|
||||
.set('organization-id', orgainzationId)
|
||||
.set('Authorization', AuthorizationHeader)
|
||||
.send(makeManualJournalRequest());
|
||||
|
||||
const journalId = response.body.id;
|
||||
|
||||
return request(app.getHttpServer())
|
||||
.delete(`/manual-journals/${journalId}`)
|
||||
.set('organization-id', orgainzationId)
|
||||
.set('Authorization', AuthorizationHeader)
|
||||
.send()
|
||||
.expect(200);
|
||||
});
|
||||
|
||||
it('/manual-journals/:id (GET)', async () => {
|
||||
const response = await request(app.getHttpServer())
|
||||
.post('/manual-journals')
|
||||
.set('organization-id', orgainzationId)
|
||||
.set('Authorization', AuthorizationHeader)
|
||||
.send(makeManualJournalRequest());
|
||||
|
||||
const journalId = response.body.id;
|
||||
|
||||
return request(app.getHttpServer())
|
||||
.get(`/manual-journals/${journalId}`)
|
||||
.set('organization-id', orgainzationId)
|
||||
.set('Authorization', AuthorizationHeader)
|
||||
.send()
|
||||
.expect(200);
|
||||
});
|
||||
|
||||
it('/manual-journals/:id (PUT)', async () => {
|
||||
const manualJournal = makeManualJournalRequest();
|
||||
const response = await request(app.getHttpServer())
|
||||
.post('/manual-journals')
|
||||
.set('organization-id', orgainzationId)
|
||||
.set('Authorization', AuthorizationHeader)
|
||||
.send(manualJournal);
|
||||
|
||||
const journalId = response.body.id;
|
||||
|
||||
return request(app.getHttpServer())
|
||||
.put(`/manual-journals/${journalId}`)
|
||||
.set('organization-id', orgainzationId)
|
||||
.set('Authorization', AuthorizationHeader)
|
||||
.send(manualJournal)
|
||||
.expect(200);
|
||||
});
|
||||
|
||||
it('/manual-journals/:id/publish (PUT)', async () => {
|
||||
const response = await request(app.getHttpServer())
|
||||
.post('/manual-journals')
|
||||
.set('organization-id', orgainzationId)
|
||||
.set('Authorization', AuthorizationHeader)
|
||||
.send(makeManualJournalRequest());
|
||||
|
||||
const journalId = response.body.id;
|
||||
|
||||
return request(app.getHttpServer())
|
||||
.put(`/manual-journals/${journalId}/publish`)
|
||||
.set('organization-id', orgainzationId)
|
||||
.set('Authorization', AuthorizationHeader)
|
||||
.send()
|
||||
.expect(200);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user