Skip to content

Commit

Permalink
fix(tests): update Trial Balance integration tests
Browse files Browse the repository at this point in the history
This commit updates the Trial Balance integration tests to the latest
API.
  • Loading branch information
jniles committed Sep 25, 2017
1 parent 1800c37 commit 83f026d
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 39 deletions.
34 changes: 11 additions & 23 deletions test/integration/generalLedger.js
Original file line number Diff line number Diff line change
@@ -1,30 +1,18 @@
/* global expect, chai, agent */

/* global agent */
const helpers = require('./helpers');

/*
* The /journal API endpoint
*/
describe('(/general_ledger) API endpoint', function () {

/**
* object containing different format of transaction to send to the
*server in order to get transactions or records
**/
var parameters = {
transactionToPost : {params : {transactions : ['TRANS2'], transactions : ['TRANS6']}},
allRecords : {number : 2},
};
describe('(/journal/transactions) API endpoint', function () {
const RECORDS_TO_POST = [
'c44619e0-3a88-4754-a750-a414fc9567bf',
'8fefadec-c036-48ce-bc4e-e307d1301960',
];

const NUM_ROW_ALL_RECORDS = 4;
const NUM_ROW_ALL_RECORDS = 6;

it('GET /general_ledger : it returns a set of records after receiving data from posting journal ', function () {

return agent.post('/trial_balance/post_transactions')
.send(parameters.transactionToPost.params)
.then(function () {
return agent.get('/general_ledger');
})
it('POST /journal/transactions will post data to the General Ledger', function () {
return agent.post('/journal/transactions')
.send({ transactions : RECORDS_TO_POST })
.then(() => agent.get('/general_ledger'))
.then(function (res) {
helpers.api.listed(res, NUM_ROW_ALL_RECORDS);
})
Expand Down
19 changes: 9 additions & 10 deletions test/integration/journal.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* global expect, chai, agent */
/* global expect, agent */
const helpers = require('./helpers');

/*
Expand All @@ -8,19 +8,19 @@ describe('(/journal) API endpoint', () => {
const RECORD_UUID = 'a5a5f950-a4c9-47f0-9a9a-2bfc3123e534';
const MISSING_RECORD_UUID = 'a5a5f950-a4c9-47f0-9a9a-2bfc3123e635';

const NUM_ROW_ALL_RECORDS = 15;
const DISTINCT_TRANSACTIONS = 7;
const NUM_ROW_ALL_RECORDS = 13;
const DISTINCT_TRANSACTIONS = 6;
const NUM_ROWS_FETCHING_TRANSACTION = 2;

it('GET /journal : it returns a set of records ', () =>
it('GET /journal returns a set of records ', () =>
agent.get('/journal')
.then((res) => {
helpers.api.listed(res, NUM_ROW_ALL_RECORDS);
})
.catch(helpers.handler)
);

it('GET /journal - returns an object of aggregate information and journal rows with aggregates flag set', () =>
it('GET /journal returns an object of aggregate information and journal rows with aggregates flag set', () =>
agent.get('/journal')
.query({ aggregates: 1 })
.then((res) => {
Expand All @@ -34,7 +34,7 @@ describe('(/journal) API endpoint', () => {
.catch(helpers.handler)
);

it('GET /journal/:record_uuid : it returns an object with the transaction and aggregate information', () =>
it('GET /journal/:record_uuid returns an object with the transaction and aggregate information', () =>
agent.get(`/journal/${RECORD_UUID}`)
.then((res) => {
expect(res).to.have.status(200);
Expand All @@ -59,7 +59,7 @@ function SearchTests() {
const description = 'unique';
const account_id = 3628;
const amount = 100;
const distinct_trans = 7;
const DISTINCT_TRANSACTIONS = 6;

it(`GET /journal?description=${description} should match one record`, () => {
const NUM_MATCHES = 1;
Expand Down Expand Up @@ -115,14 +115,13 @@ function SearchTests() {
.catch(helpers.handler);
});

it('GET /journal/ count returns return the numbers of transaction from Journal', () => {
it('GET /journal/count returns return the numbers of transactions from Journal', () => {
return agent.get('/journal/count')
.then((res) => {
expect(res).to.have.status(200);
expect(res).to.be.json;
expect(res.body[0].number_transactions).to.equal(distinct_trans);
expect(res.body[0].number_transactions).to.equal(DISTINCT_TRANSACTIONS);
})
.catch(helpers.handler);
});

}
11 changes: 5 additions & 6 deletions test/integration/trialBalance.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,27 +58,26 @@ describe('(/journal/trialbalance) API endpoint', () => {
expect(summary).to.have.length(2);

// all accounts have 0 balance before
expect(summary[0].balance_before).to.equal(0);
expect(summary[1].balance_before).to.equal(0);
expect(summary[0].balance_before).to.equal(25);
expect(summary[1].balance_before).to.equal(-25);

expect(summary[0].debit_equiv).to.equal(100);
expect(summary[0].debit_equiv).to.equal(75);
expect(summary[1].debit_equiv).to.equal(0);

expect(summary[0].credit_equiv).to.equal(0);
expect(summary[1].credit_equiv).to.equal(100);
expect(summary[1].credit_equiv).to.equal(75)

expect(summary[0].balance_final).to.equal(100);
expect(summary[1].balance_final).to.equal(-100);
})
.catch(helpers.handler);
});

it.skip('POST /journal/transactions posts the a transaction to general_ledger and remove it form the posting_general', () => {
it('POST /journal/transactions posts the a transaction to general_ledger and remove it form the posting_general', () => {
return agent.post('/journal/transactions')
.send(formatParams(POSTING_TXNS))
.then((res) => {
expect(res).to.have.status(201);
expect(res).to.be.json;
return agent.get(`/journal/${POSTING_TXNS[0]}`);
})
.then((res) => {
Expand Down

0 comments on commit 83f026d

Please sign in to comment.