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:
97
packages/server/test/bank-rules.e2e-spec.ts
Normal file
97
packages/server/test/bank-rules.e2e-spec.ts
Normal file
@@ -0,0 +1,97 @@
|
||||
import * as request from 'supertest';
|
||||
import { faker } from '@faker-js/faker';
|
||||
import { app, AuthorizationHeader, orgainzationId } from './init-app-test';
|
||||
|
||||
const requestBankRule = () => ({
|
||||
name: faker.company.name(),
|
||||
order: 1,
|
||||
applyIfAccountId: 1001,
|
||||
applyIfTransactionType: 'deposit',
|
||||
conditions: [
|
||||
{
|
||||
field: 'description',
|
||||
comparator: 'contains',
|
||||
value: faker.finance.transactionDescription(),
|
||||
},
|
||||
],
|
||||
assignCategory: 'Deposit',
|
||||
assignAccountId: 1002,
|
||||
assignPayee: faker.company.name(),
|
||||
assignMemo: faker.lorem.sentence(),
|
||||
});
|
||||
|
||||
describe('Bank Rules (e2e)', () => {
|
||||
it('/banking/rules (POST)', () => {
|
||||
return request(app.getHttpServer())
|
||||
.post('/banking/rules')
|
||||
.set('organization-id', orgainzationId)
|
||||
.set('Authorization', AuthorizationHeader)
|
||||
.send(requestBankRule())
|
||||
.expect(201);
|
||||
});
|
||||
|
||||
it('/banking/rules/:id (PUT)', async () => {
|
||||
const response = await request(app.getHttpServer())
|
||||
.post('/banking/rules')
|
||||
.set('organization-id', orgainzationId)
|
||||
.set('Authorization', AuthorizationHeader)
|
||||
.send(requestBankRule());
|
||||
|
||||
const ruleId = response.body.id;
|
||||
|
||||
return request(app.getHttpServer())
|
||||
.put(`/banking/rules/${ruleId}`)
|
||||
.set('organization-id', orgainzationId)
|
||||
.set('Authorization', AuthorizationHeader)
|
||||
.send(requestBankRule())
|
||||
.expect(200);
|
||||
});
|
||||
|
||||
it('/banking/rules/:id (DELETE)', async () => {
|
||||
const response = await request(app.getHttpServer())
|
||||
.post('/banking/rules')
|
||||
.set('organization-id', orgainzationId)
|
||||
.set('Authorization', AuthorizationHeader)
|
||||
.send(requestBankRule());
|
||||
|
||||
const ruleId = response.body.id;
|
||||
|
||||
return request(app.getHttpServer())
|
||||
.delete(`/banking/rules/${ruleId}`)
|
||||
.set('organization-id', orgainzationId)
|
||||
.set('Authorization', AuthorizationHeader)
|
||||
.expect(200);
|
||||
});
|
||||
|
||||
it('/banking/rules/:id (GET)', async () => {
|
||||
const response = await request(app.getHttpServer())
|
||||
.post('/banking/rules')
|
||||
.set('organization-id', orgainzationId)
|
||||
.set('Authorization', AuthorizationHeader)
|
||||
.send(requestBankRule());
|
||||
|
||||
const ruleId = response.body.id;
|
||||
|
||||
return request(app.getHttpServer())
|
||||
.get(`/banking/rules/${ruleId}`)
|
||||
.set('organization-id', orgainzationId)
|
||||
.set('Authorization', AuthorizationHeader)
|
||||
.expect(200);
|
||||
});
|
||||
|
||||
it('/banking/rules (GET)', async () => {
|
||||
const response = await request(app.getHttpServer())
|
||||
.post('/banking/rules')
|
||||
.set('organization-id', orgainzationId)
|
||||
.set('Authorization', AuthorizationHeader)
|
||||
.send(requestBankRule());
|
||||
|
||||
const ruleId = response.body.id;
|
||||
|
||||
return request(app.getHttpServer())
|
||||
.get(`/banking/rules/${ruleId}`)
|
||||
.set('organization-id', orgainzationId)
|
||||
.set('Authorization', AuthorizationHeader)
|
||||
.expect(200);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user