blob: 9e8ba9a4062b39dd3f4b1f3252d806e0c1c3a5c4 (
plain) (
tree)
|
|
import { BigNumber } from '@0x/utils';
import * as chai from 'chai';
import 'mocha';
import { OasisMarket } from '../../../src/data_sources/oasis';
import { TokenOrderbookSnapshot as TokenOrder } from '../../../src/entities';
import { parseOasisOrder } from '../../../src/parsers/oasis_orders';
import { OrderType } from '../../../src/types';
import { chaiSetup } from '../../utils/chai_setup';
chaiSetup.configure();
const expect = chai.expect;
// tslint:disable:custom-no-magic-numbers
describe('oasis_orders', () => {
describe('parseOasisOrder', () => {
it('converts oasisOrder to TokenOrder entity', () => {
const oasisOrder: [string, BigNumber] = ['0.5', new BigNumber(10)];
const oasisMarket: OasisMarket = {
id: 'ABCDEF',
base: 'DEF',
quote: 'ABC',
buyVol: 100,
sellVol: 200,
price: 1,
high: 1,
low: 0,
};
const observedTimestamp: number = Date.now();
const orderType: OrderType = 'bid';
const source: string = 'oasis';
const expected = new TokenOrder();
expected.source = 'oasis';
expected.observedTimestamp = observedTimestamp;
expected.orderType = 'bid';
expected.price = new BigNumber(0.5);
expected.baseAssetSymbol = 'DEF';
expected.baseAssetAddress = null;
expected.baseVolume = new BigNumber(5);
expected.quoteAssetSymbol = 'ABC';
expected.quoteAssetAddress = null;
expected.quoteVolume = new BigNumber(10);
const actual = parseOasisOrder(oasisMarket, observedTimestamp, orderType, source, oasisOrder);
expect(actual).deep.equal(expected);
});
});
});
|