Skip to content

Commit

Permalink
test: convert tests to TypeScript
Browse files Browse the repository at this point in the history
  • Loading branch information
tony-ho committed May 18, 2019
1 parent b47ad75 commit 785fb83
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 31 deletions.
63 changes: 32 additions & 31 deletions __tests__/binance-oco.test.js → __tests__/binance-oco.test.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable @typescript-eslint/explicit-function-return-type */
/* eslint-disable @typescript-eslint/no-var-requires */
jest.mock("binance-api-node");

Expand Down Expand Up @@ -366,7 +367,7 @@ describe("order validation", () => {
amount: 1,
buyPrice: 0
})
).resolves.toBe();
).resolves.not.toBeDefined();
expect(mockOrderTest).not.toBeCalled();
});

Expand All @@ -377,7 +378,7 @@ describe("order validation", () => {
amount: 1,
stopPrice: 0.001
})
).resolves.toBe();
).resolves.not.toBeDefined();
expect(mockOrderTest).not.toBeCalled();
});

Expand All @@ -388,7 +389,7 @@ describe("order validation", () => {
amount: 1,
targetPrice: 0.003
})
).resolves.toBe();
).resolves.not.toBeDefined();
expect(mockOrderTest).not.toBeCalled();
});

Expand All @@ -400,7 +401,7 @@ describe("order validation", () => {
stopPrice: 0.001,
targetPrice: 0.003
})
).resolves.toBe();
).resolves.not.toBeDefined();
expect(mockOrderTest).toBeCalledWith({
symbol: "BNBBTC",
side: "SELL",
Expand All @@ -419,7 +420,7 @@ describe("order validation", () => {
targetPrice: 0.003,
scaleOutAmount: 1
})
).resolves.toBe();
).resolves.not.toBeDefined();
expect(mockOrderTest).toBeCalledWith({
symbol: "BNBBTC",
side: "SELL",
Expand All @@ -445,7 +446,7 @@ describe("order validation", () => {
buyPrice: 0.002,
stopPrice: 0.001
})
).resolves.toBe();
).resolves.not.toBeDefined();
expect(mockOrderTest).toBeCalledWith({
symbol: "BNBBTC",
side: "SELL",
Expand All @@ -464,7 +465,7 @@ describe("order validation", () => {
buyPrice: 0.002,
targetPrice: 0.003
})
).resolves.toBe();
).resolves.not.toBeDefined();
expect(mockOrderTest).toBeCalledWith({
symbol: "BNBBTC",
side: "SELL",
Expand All @@ -483,7 +484,7 @@ describe("order validation", () => {
stopPrice: 0.001,
targetPrice: 0.003
})
).resolves.toBe();
).resolves.not.toBeDefined();
expect(mockOrderTest).toBeCalledWith({
symbol: "BNBBTC",
side: "SELL",
Expand Down Expand Up @@ -511,7 +512,7 @@ describe("order validation", () => {
targetPrice: 0.003,
scaleOutAmount: 1
})
).resolves.toBe();
).resolves.not.toBeDefined();
expect(mockOrderTest).toBeCalledWith({
symbol: "BNBBTC",
side: "SELL",
Expand Down Expand Up @@ -541,7 +542,7 @@ describe("orders", () => {
amount: 1,
buyPrice: 0
})
).resolves.toBe();
).resolves.not.toBeDefined();
expect(mockOrder).toBeCalledWith({
symbol: "BNBBTC",
side: "BUY",
Expand All @@ -557,7 +558,7 @@ describe("orders", () => {
amount: 1,
buyPrice: 0.001
})
).resolves.toBe();
).resolves.not.toBeDefined();
expect(mockOrder).toBeCalledWith({
symbol: "BNBBTC",
side: "BUY",
Expand All @@ -574,7 +575,7 @@ describe("orders", () => {
amount: 1,
buyPrice: 0.003
})
).resolves.toBe();
).resolves.not.toBeDefined();
expect(mockOrder).toBeCalledWith({
symbol: "BNBBTC",
side: "BUY",
Expand All @@ -594,7 +595,7 @@ describe("orders", () => {
buyPrice: 0.003,
buyLimitPrice: 0.004
})
).resolves.toBe();
).resolves.not.toBeDefined();
expect(mockOrder).toBeCalledWith({
symbol: "BNBBTC",
side: "BUY",
Expand Down Expand Up @@ -627,7 +628,7 @@ describe("orders", () => {
amount: 1,
buyPrice: 0.002
})
).resolves.toBe();
).resolves.not.toBeDefined();
expect(mockOrder).toBeCalled();
expect(getOrderFilled).toBeCalledWith({ symbol: "BNBBTC", orderId: "1" });
});
Expand All @@ -640,7 +641,7 @@ describe("orders", () => {
buyPrice: 0.002,
cancelPrice: 0.001
})
).resolves.toBe();
).resolves.not.toBeDefined();
expect(mockOrder).toBeCalled();
expect(mockCancel).not.toBeCalled();
});
Expand Down Expand Up @@ -714,7 +715,7 @@ describe("orders", () => {
amount: 1,
stopPrice: 0.001
})
).resolves.toBe();
).resolves.not.toBeDefined();
expect(mockOrder).toBeCalledWith({
symbol: "BNBBTC",
side: "SELL",
Expand All @@ -734,7 +735,7 @@ describe("orders", () => {
stopPrice: 0.002,
stopLimitPrice: 0.001
})
).resolves.toBe();
).resolves.not.toBeDefined();
expect(mockOrder).toBeCalledWith({
symbol: "BNBBTC",
side: "SELL",
Expand All @@ -753,7 +754,7 @@ describe("orders", () => {
amount: 1,
targetPrice: 0.003
})
).resolves.toBe();
).resolves.not.toBeDefined();
expect(mockOrder).toBeCalledWith({
symbol: "BNBBTC",
side: "SELL",
Expand All @@ -771,7 +772,7 @@ describe("orders", () => {
stopPrice: 0.001,
targetPrice: 0.003
})
).resolves.toBe();
).resolves.not.toBeDefined();
expect(mockOrder).toBeCalledWith({
symbol: "BNBBTC",
side: "SELL",
Expand Down Expand Up @@ -799,7 +800,7 @@ describe("orders", () => {
targetPrice: 0.003,
scaleOutAmount: 1
})
).resolves.toBe();
).resolves.not.toBeDefined();
expect(mockOrder).toBeCalledWith({
symbol: "BNBBTC",
side: "SELL",
Expand Down Expand Up @@ -847,7 +848,7 @@ describe("orders", () => {
stopPrice: 0.001,
targetPrice: 0.003
})
).resolves.toBe();
).resolves.not.toBeDefined();
expect(mockOrder).toBeCalled();
expect(getOrderFilled).toBeCalledWith({ symbol: "BNBBTC", orderId: "1" });
});
Expand Down Expand Up @@ -894,7 +895,7 @@ describe("orders", () => {
buyPrice: 0.002,
stopPrice: 0.001
})
).resolves.toBe();
).resolves.not.toBeDefined();
expect(mockOrder).toBeCalledWith({
symbol: "BNBBTC",
side: "BUY",
Expand All @@ -921,7 +922,7 @@ describe("orders", () => {
buyPrice: 0.002,
targetPrice: 0.003
})
).resolves.toBe();
).resolves.not.toBeDefined();
expect(mockOrder).toBeCalledWith({
symbol: "BNBBTC",
side: "BUY",
Expand All @@ -947,7 +948,7 @@ describe("orders", () => {
targetPrice: 0.003,
scaleOutAmount: 0.5
})
).resolves.toBe();
).resolves.not.toBeDefined();
expect(mockOrder).toBeCalledWith({
symbol: "BNBBTC",
side: "BUY",
Expand All @@ -973,7 +974,7 @@ describe("orders", () => {
stopPrice: 0.001,
nonBnbFees: true
})
).resolves.toBe();
).resolves.not.toBeDefined();
expect(mockOrder).toBeCalledWith({
symbol: "BNBBTC",
side: "SELL",
Expand Down Expand Up @@ -1015,7 +1016,7 @@ describe("orders", () => {
buyPrice: 0,
stopPrice: 4000
})
).resolves.toBe();
).resolves.not.toBeDefined();
expect(orderWithNonBnbCommission).toBeCalledWith({
symbol: "BTCUSDT",
side: "SELL",
Expand Down Expand Up @@ -1064,7 +1065,7 @@ describe("orders", () => {
buyPrice: 5000,
stopPrice: 4000
})
).resolves.toBe();
).resolves.not.toBeDefined();
expect(mockOrder).toBeCalledWith({
symbol: "BTCUSDT",
side: "SELL",
Expand All @@ -1085,7 +1086,7 @@ describe("orders", () => {
stopPrice: 0.001,
targetPrice: 0.003
})
).resolves.toBe();
).resolves.not.toBeDefined();
expect(mockOrder).toBeCalledWith({
symbol: "BNBBTC",
side: "BUY",
Expand Down Expand Up @@ -1121,7 +1122,7 @@ describe("orders", () => {
targetPrice: 0.003,
scaleOutAmount: 1
})
).resolves.toBe();
).resolves.not.toBeDefined();
expect(mockOrder).toBeCalledWith({
symbol: "BNBBTC",
side: "BUY",
Expand Down Expand Up @@ -1191,7 +1192,7 @@ describe("orders", () => {
stopPrice: 0.001,
targetPrice: 0.003
})
).resolves.toBe();
).resolves.not.toBeDefined();
expect(mockOrder).toBeCalledWith({
symbol: "BNBBTC",
side: "BUY",
Expand Down Expand Up @@ -1228,7 +1229,7 @@ describe("orders", () => {
targetPrice: 0.003,
scaleOutAmount: 1
})
).resolves.toBe();
).resolves.not.toBeDefined();
expect(mockOrder).toBeCalledWith({
symbol: "BNBBTC",
side: "BUY",
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
"yargs": "^11.0.0"
},
"devDependencies": {
"@types/jest": "^24.0.13",
"@types/joi": "^14.3.3",
"@types/node": "^12.0.0",
"@typescript-eslint/eslint-plugin": "^1.9.0",
Expand Down

0 comments on commit 785fb83

Please sign in to comment.