Skip to content

Commit

Permalink
#633 Add getOrder test
Browse files Browse the repository at this point in the history
  • Loading branch information
priecint committed Aug 8, 2016
1 parent 95d3662 commit 22f4f72
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/modules/bids-asks/helpers/get-order.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,14 @@
* Author: priecint
*/

/**
*
* @param {String} orderID
* @param {String} marketID
* @param {String} type
* @param {Object} marketOrderBooks
* @return {Object|null}
*/
export default function (orderID, marketID, type, marketOrderBooks) {
const marketOrderBook = marketOrderBooks[marketID];

Expand Down
45 changes: 45 additions & 0 deletions test/bids-asks/helpers/get-order-test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
/*
* Author: priecint
*/
import { assert } from 'chai';
import { BID } from "../../../src/modules/bids-asks/constants/bids-asks-types";

describe('modules/bids-asks/helpers/get-order.js', () => {
const getOrder = require('../../../src/modules/bids-asks/helpers/get-order').default;
it(`shouldn't return order if it's not there`, () => {
assert.isNull(getOrder('orderID', 'marketID', BID, {}));
assert.isNull(getOrder('orderID', 'marketID', BID, {sell: {}}));
assert.isNull(getOrder('orderID', 'marketID', BID, {buy: {}}));
});

it(`should return order if it's there`, () => {
const order = getOrder('0xdbd851cc394595f9c50f32c1554059ec343471b49f84a4b72c44589a25f70ff3', 'testMarketID', BID, {
testMarketID: {
buy: {
'0xdbd851cc394595f9c50f32c1554059ec343471b49f84a4b72c44589a25f70ff3': {
amount: '10',
block: 1234,
id: '0xdbd851cc394595f9c50f32c1554059ec343471b49f84a4b72c44589a25f70ff3',
market: 'testMarketID',
outcome: '2',
owner: '0x7c0d52faab596c08f423e3478aebc6205f3f5d8c',
price: '0.42',
type: 'buy'
}
}
}
}
);
assert.deepEqual(order, {
amount: '10',
block: 1234,
id: '0xdbd851cc394595f9c50f32c1554059ec343471b49f84a4b72c44589a25f70ff3',
market: 'testMarketID',
outcome: '2',
owner: '0x7c0d52faab596c08f423e3478aebc6205f3f5d8c',
price: '0.42',
type: 'buy'
}
);
});
});

0 comments on commit 22f4f72

Please sign in to comment.