Skip to content
This repository has been archived by the owner on Apr 2, 2024. It is now read-only.

Commit

Permalink
test: Add test case for limit buy orders
Browse files Browse the repository at this point in the history
  • Loading branch information
bennycode committed Jul 2, 2022
1 parent 38c6a61 commit c94a7d5
Show file tree
Hide file tree
Showing 4 changed files with 2,459 additions and 2,428 deletions.
3 changes: 2 additions & 1 deletion jasmine.json
Expand Up @@ -3,5 +3,6 @@
"random": true,
"spec_dir": "src",
"spec_files": ["**/*.test.ts", "**/*.test.node.ts"],
"stopSpecOnExpectationFailure": true
"stopSpecOnExpectationFailure": true,
"verboseDeprecations": true
}
12 changes: 6 additions & 6 deletions package.json
Expand Up @@ -11,16 +11,16 @@
"bufferutil": "4.0.6",
"reconnecting-websocket": "4.4.0",
"utf-8-validate": "5.0.9",
"ws": "8.5.0"
"ws": "8.8.0"
},
"description": "Coinbase Pro API for Node.js, written in TypeScript and covered by tests.",
"devDependencies": {
"@types/jasmine": "4.0.3",
"@typescript-eslint/eslint-plugin": "5.30.0",
"@typescript-eslint/parser": "5.30.0",
"@typescript-eslint/eslint-plugin": "5.30.3",
"@typescript-eslint/parser": "5.30.3",
"cross-env": "7.0.3",
"dotenv-defaults": "5.0.2",
"eslint": "8.18.0",
"eslint": "8.19.0",
"eslint-config-prettier": "8.5.0",
"eslint-plugin-prettier": "4.2.1",
"eslint-plugin-sort-keys-fix": "1.1.2",
Expand All @@ -35,8 +35,8 @@
"pretty-quick": "3.1.3",
"rimraf": "3.0.2",
"ts-node": "10.8.1",
"typedoc": "0.23.2",
"typedoc-plugin-markdown": "3.12.1",
"typedoc": "0.23.4",
"typedoc-plugin-markdown": "3.13.2",
"typescript": "4.7.4"
},
"engines": {
Expand Down
40 changes: 40 additions & 0 deletions src/order/OrderAPI.test.ts
Expand Up @@ -45,6 +45,46 @@ describe('OrderAPI', () => {
expect(placedOrder.size).toBe('0.10000000');
expect(placedOrder.status).toBe(OrderStatus.PENDING);
});

it('places limit buy orders', async () => {
nock(global.REST_URL)
.post(OrderAPI.URL.ORDERS)
.query(true)
.reply((_uri, body) => {
const newOrder: NewOrder = typeof body === 'string' ? JSON.parse(body) : body;

return [
200,
JSON.stringify({
created_at: '2022-07-02T15:29:10.132Z',
executed_value: '0.0000000000000000',
fill_fees: '0.0000000000000000',
filled_size: '0.00000000',
funds: '207850.8486540300000000',
id: 'b0ba16c1-749c-4f96-b2e5-95192d721f92',
post_only: false,
product_id: newOrder.product_id,
settled: false,
side: newOrder.side,
size: '1.00000000',
status: OrderStatus.PENDING,
stp: SelfTradePrevention.DECREMENT_AND_CANCEL,
type: newOrder.type,
}),
];
});

const placedOrder = await global.client.rest.order.placeOrder({
price: '18427.33',
product_id: 'BTC-EUR',
side: OrderSide.BUY,
size: '1',
type: OrderType.LIMIT,
});

expect(placedOrder.size).toBe('1.00000000');
expect(placedOrder.status).toBe(OrderStatus.PENDING);
});
});

describe('getOrders', () => {
Expand Down

0 comments on commit c94a7d5

Please sign in to comment.