diff --git a/.gitignore b/.gitignore index 369bcd4..5282197 100644 --- a/.gitignore +++ b/.gitignore @@ -64,5 +64,8 @@ typings/ # dotenv environment variables file .env +# credential settings +src/tests/api-credentials-settings.ts -# End of https://www.gitignore.io/api/node \ No newline at end of file + +# End of https://www.gitignore.io/api/node diff --git a/package-lock.json b/package-lock.json index a701009..ff61892 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,15 +1,27 @@ { "name": "bittrex-rx", - "version": "1.1.3", + "version": "1.1.7", "lockfileVersion": 1, "requires": true, "dependencies": { + "@types/chai": { + "version": "4.0.10", + "resolved": "https://registry.npmjs.org/@types/chai/-/chai-4.0.10.tgz", + "integrity": "sha512-Ejh1AXTY8lm+x91X/yar3G2z4x9RyKwdTVdyyu7Xj3dNB35fMNCnEWqTO9FgS3zjzlRNqk1MruYhgb8yhRN9rA==", + "dev": true + }, "@types/jquery": { "version": "3.2.16", "resolved": "https://registry.npmjs.org/@types/jquery/-/jquery-3.2.16.tgz", "integrity": "sha512-q2WC02YxQoX2nY1HRKlYGHpGP1saPmD7GN0pwCDlTz35a4eOtJG+aHRlXyjCuXokUukSrR2aXyBhSW3j+jPc0A==", "dev": true }, + "@types/mocha": { + "version": "2.2.44", + "resolved": "https://registry.npmjs.org/@types/mocha/-/mocha-2.2.44.tgz", + "integrity": "sha512-k2tWTQU8G4+iSMvqKi0Q9IIsWAp/n8xzdZS4Q4YVIltApoMA00wFBFdlJnmoaK1/z7B0Cy0yPe6GgXteSmdUNw==", + "dev": true + }, "@types/node": { "version": "7.0.48", "resolved": "https://registry.npmjs.org/@types/node/-/node-7.0.48.tgz", @@ -48,6 +60,48 @@ "integrity": "sha1-iYUI2iIm84DfkEcoRWhJwVAaSw0=", "dev": true }, + "assertion-error": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/assertion-error/-/assertion-error-1.0.2.tgz", + "integrity": "sha1-E8pRXYYgbaC6xm6DTdOX2HWBCUw=", + "dev": true + }, + "balanced-match": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.0.tgz", + "integrity": "sha1-ibTRmasr7kneFk6gK4nORi1xt2c=", + "dev": true + }, + "brace-expansion": { + "version": "1.1.8", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.8.tgz", + "integrity": "sha1-wHshHHyVLsH479Uad+8NHTmQopI=", + "dev": true, + "requires": { + "balanced-match": "1.0.0", + "concat-map": "0.0.1" + } + }, + "browser-stdout": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/browser-stdout/-/browser-stdout-1.3.0.tgz", + "integrity": "sha1-81HTKWnTL6XXpVZxVCY9korjvR8=", + "dev": true + }, + "chai": { + "version": "4.1.2", + "resolved": "https://registry.npmjs.org/chai/-/chai-4.1.2.tgz", + "integrity": "sha1-D2RYS6ZC8PKs4oBiefTwbKI61zw=", + "dev": true, + "requires": { + "assertion-error": "1.0.2", + "check-error": "1.0.2", + "deep-eql": "3.0.1", + "get-func-name": "2.0.0", + "pathval": "1.1.0", + "type-detect": "4.0.5" + } + }, "chalk": { "version": "2.3.0", "resolved": "https://registry.npmjs.org/chalk/-/chalk-2.3.0.tgz", @@ -59,6 +113,12 @@ "supports-color": "4.5.0" } }, + "check-error": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/check-error/-/check-error-1.0.2.tgz", + "integrity": "sha1-V00xLt2Iu13YkS6Sht1sCu1KrII=", + "dev": true + }, "color-convert": { "version": "1.9.1", "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-1.9.1.tgz", @@ -74,6 +134,18 @@ "integrity": "sha1-p9BVi9icQveV3UIyj3QIMcpTvCU=", "dev": true }, + "commander": { + "version": "2.11.0", + "resolved": "https://registry.npmjs.org/commander/-/commander-2.11.0.tgz", + "integrity": "sha512-b0553uYA5YAEGgyYIGYROzKQ7X5RAqedkfjiZxwi0kL1g3bOaBNNZfYkzt/CL0umgD5wc9Jec2FbB98CjkMRvQ==", + "dev": true + }, + "concat-map": { + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", + "integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=", + "dev": true + }, "debug": { "version": "2.6.9", "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", @@ -82,6 +154,15 @@ "ms": "2.0.0" } }, + "deep-eql": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/deep-eql/-/deep-eql-3.0.1.tgz", + "integrity": "sha512-+QeIQyN5ZuO+3Uk5DYh6/1eKO0m0YmJFGNmFHGACpf1ClL1nmlV/p4gNgbl2pJGxgXb4faqo6UE+M5ACEMyVcw==", + "dev": true, + "requires": { + "type-detect": "4.0.5" + } + }, "diff": { "version": "3.4.0", "resolved": "https://registry.npmjs.org/diff/-/diff-3.4.0.tgz", @@ -102,12 +183,50 @@ "integrity": "sha1-G2HAViGQqN/2rjuyzwIAyhMLhtQ=", "dev": true }, + "fs.realpath": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", + "integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8=", + "dev": true + }, + "get-func-name": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/get-func-name/-/get-func-name-2.0.0.tgz", + "integrity": "sha1-6td0q+5y4gQJQzoGY2YCPdaIekE=", + "dev": true + }, + "glob": { + "version": "7.1.2", + "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.2.tgz", + "integrity": "sha512-MJTUg1kjuLeQCJ+ccE4Vpa6kKVXkPYJ2mOCQyUuKLcLQsdrMCpBPUi8qVE6+YuaJkozeA9NusTAw3hLr8Xe5EQ==", + "dev": true, + "requires": { + "fs.realpath": "1.0.0", + "inflight": "1.0.6", + "inherits": "2.0.3", + "minimatch": "3.0.4", + "once": "1.4.0", + "path-is-absolute": "1.0.1" + } + }, + "growl": { + "version": "1.10.3", + "resolved": "https://registry.npmjs.org/growl/-/growl-1.10.3.tgz", + "integrity": "sha512-hKlsbA5Vu3xsh1Cg3J7jSmX/WaW6A5oBeqzM88oNbCRQFz+zUaXm6yxS4RVytp1scBoJzSYl4YAEOQIt6O8V1Q==", + "dev": true + }, "has-flag": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-2.0.0.tgz", "integrity": "sha1-6CB68cx7MNRGzHC3NLXovhj4jVE=", "dev": true }, + "he": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/he/-/he-1.1.1.tgz", + "integrity": "sha1-k0EP0hsAlzUVH4howvJx80J+I/0=", + "dev": true + }, "homedir-polyfill": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/homedir-polyfill/-/homedir-polyfill-1.0.1.tgz", @@ -122,6 +241,22 @@ "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.19.tgz", "integrity": "sha512-oTZqweIP51xaGPI4uPa56/Pri/480R+mo7SeU+YETByQNhDG55ycFyNLIgta9vXhILrxXDmF7ZGhqZIcuN0gJQ==" }, + "inflight": { + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz", + "integrity": "sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk=", + "dev": true, + "requires": { + "once": "1.4.0", + "wrappy": "1.0.2" + } + }, + "inherits": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz", + "integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4=", + "dev": true + }, "is-stream": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/is-stream/-/is-stream-1.1.0.tgz", @@ -148,6 +283,15 @@ "integrity": "sha1-Uq06M5zPEM5itAQLcI/nByRLi5Y=", "dev": true }, + "minimatch": { + "version": "3.0.4", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz", + "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==", + "dev": true, + "requires": { + "brace-expansion": "1.1.8" + } + }, "minimist": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.0.tgz", @@ -171,6 +315,50 @@ } } }, + "mocha": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/mocha/-/mocha-4.0.1.tgz", + "integrity": "sha512-evDmhkoA+cBNiQQQdSKZa2b9+W2mpLoj50367lhy+Klnx9OV8XlCIhigUnn1gaTFLQCa0kdNhEGDr0hCXOQFDw==", + "dev": true, + "requires": { + "browser-stdout": "1.3.0", + "commander": "2.11.0", + "debug": "3.1.0", + "diff": "3.3.1", + "escape-string-regexp": "1.0.5", + "glob": "7.1.2", + "growl": "1.10.3", + "he": "1.1.1", + "mkdirp": "0.5.1", + "supports-color": "4.4.0" + }, + "dependencies": { + "debug": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/debug/-/debug-3.1.0.tgz", + "integrity": "sha512-OX8XqP7/1a9cqkxYw2yXss15f26NKWBpDXQd0/uK/KPqdQhxbPa994hnzjcE2VqQpDslf55723cKPUOGSmMY3g==", + "dev": true, + "requires": { + "ms": "2.0.0" + } + }, + "diff": { + "version": "3.3.1", + "resolved": "https://registry.npmjs.org/diff/-/diff-3.3.1.tgz", + "integrity": "sha512-MKPHZDMB0o6yHyDryUOScqZibp914ksXwAMYMTHj6KO8UeKsRYNJD3oNCKjTqZon+V488P7N/HzXF8t7ZR95ww==", + "dev": true + }, + "supports-color": { + "version": "4.4.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-4.4.0.tgz", + "integrity": "sha512-rKC3+DyXWgK0ZLKwmRsrkyHVZAjNkfzeehuFWdGGcqGDTZFH73+RH6S/RDAAxl9GusSjZSUWYLmT9N5pzXFOXQ==", + "dev": true, + "requires": { + "has-flag": "2.0.0" + } + } + } + }, "ms": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", @@ -190,12 +378,33 @@ "is-stream": "1.1.0" } }, + "once": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", + "integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=", + "dev": true, + "requires": { + "wrappy": "1.0.2" + } + }, "parse-passwd": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/parse-passwd/-/parse-passwd-1.0.0.tgz", "integrity": "sha1-bVuTSkVpk7I9N/QKOC1vFmao5cY=", "dev": true }, + "path-is-absolute": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", + "integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18=", + "dev": true + }, + "pathval": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/pathval/-/pathval-1.1.0.tgz", + "integrity": "sha1-uULm1L3mUwBe9rcTYd74cn0GReA=", + "dev": true + }, "rxjs": { "version": "5.5.2", "resolved": "https://registry.npmjs.org/rxjs/-/rxjs-5.5.2.tgz", @@ -281,6 +490,12 @@ "strip-json-comments": "2.0.1" } }, + "type-detect": { + "version": "4.0.5", + "resolved": "https://registry.npmjs.org/type-detect/-/type-detect-4.0.5.tgz", + "integrity": "sha512-N9IvkQslUGYGC24RkJk1ba99foK6TkwC2FHAEBlQFBP0RxQZS8ZpJuAZcwiY/w9ZJHFQb1aOXBI60OdxhTrwEQ==", + "dev": true + }, "typedarray-to-buffer": { "version": "3.1.2", "resolved": "https://registry.npmjs.org/typedarray-to-buffer/-/typedarray-to-buffer-3.1.2.tgz", @@ -315,6 +530,12 @@ "yaeti": "0.0.6" } }, + "wrappy": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", + "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=", + "dev": true + }, "yaeti": { "version": "0.0.6", "resolved": "https://registry.npmjs.org/yaeti/-/yaeti-0.0.6.tgz", diff --git a/package.json b/package.json index f86af26..922a3da 100644 --- a/package.json +++ b/package.json @@ -5,7 +5,7 @@ "scripts": { "build": "tsc", "prepublish": "npm run build", - "test": "echo \"Error: no test specified\" && exit 1" + "test": "mocha -r ts-node/register ./src/tests/index.ts" }, "main": "build/index.js", "types": "build/index.d.ts", @@ -44,8 +44,12 @@ "signalr-client": "0.0.17" }, "devDependencies": { + "@types/chai": "^4.0.10", + "@types/mocha": "^2.2.44", "@types/node-fetch": "^1.6.7", "@types/signalr": "^2.2.34", + "chai": "^4.1.2", + "mocha": "^4.0.1", "ts-node": "^3.3.0", "typescript": "^2.6.1" } diff --git a/src/tests/api-credentials-settings-format.ts b/src/tests/api-credentials-settings-format.ts new file mode 100644 index 0000000..59d7ac6 --- /dev/null +++ b/src/tests/api-credentials-settings-format.ts @@ -0,0 +1,7 @@ + +export class ApiCredentialsSettings { + static key: string = null; + static secret: string = null; +} + + diff --git a/src/tests/index.ts b/src/tests/index.ts new file mode 100644 index 0000000..8006f2d --- /dev/null +++ b/src/tests/index.ts @@ -0,0 +1,2 @@ +import './public-tests'; +import './private-tests'; diff --git a/src/tests/private-tests.ts b/src/tests/private-tests.ts new file mode 100644 index 0000000..6baa34f --- /dev/null +++ b/src/tests/private-tests.ts @@ -0,0 +1,96 @@ + +import { + BittrexRxClient, + OrderConditionalTypeValue, + TickIntervalValue, + TimeInEffectValue, + MarketOrderValue, + Model +} from '../index' +import * as chai from "chai"; +const assert = chai.assert; +import { Observable } from 'rxjs'; + +import { ApiCredentialsSettings } from "./api-credentials-settings"; + +describe("BitttrexRx Private Methods", () => { + let bittrexRx: BittrexRxClient; + + before(done => { + bittrexRx = new BittrexRxClient(); + bittrexRx.apiCredentials(ApiCredentialsSettings.key, ApiCredentialsSettings.secret); + done(); + }); + + describe("#getBalances()", () => { + it("should respond with an instance of Balance", done => { + bittrexRx.getBalances() + .subscribe(json => { + assert.instanceOf(json[0], Model.Balance); + done(); + }, + done + ); + }).timeout(60000); + }); + + describe("#getBalance()", () => { + it("should respond with an instance of Balance", done => { + bittrexRx.getBalance('BTC') + .subscribe(json => { + assert.instanceOf(json, Model.Balance); + done(); + }, + done + ); + }).timeout(60000); + }); + + describe("#getOrderHistory()", () => { + it("should respond with an instance of OrderHistoryOrderItem", done => { + bittrexRx.getOrderHistory() + .subscribe(json => { + assert.instanceOf(json[0], Model.OrderHistoryOrderItem); + done(); + }, + done + ); + }).timeout(60000); + }); + + describe("#getDepositAddress()", () => { + it("should respond with an instance of DepositAddress", done => { + bittrexRx.getDepositAddress('BTC') + .subscribe(json => { + assert.instanceOf(json, Model.DepositAddress); + done(); + }, + done + ); + }).timeout(60000); + }); + + describe("#getDepositHistory()", () => { + it("should respond with an instance of Transaction", done => { + bittrexRx.getDepositHistory('BTC') + .subscribe(json => { + assert.instanceOf(json[0], Model.Transaction); + done(); + }, + done + ); + }).timeout(60000); + }); + + describe("#getWithdrawalHistory()", () => { + it("should respond with an instance of WithdrawalTransaction", done => { + bittrexRx.getWithdrawalHistory('BTC') + .subscribe(json => { + assert.instanceOf(json[0], Model.WithdrawalTransaction, 'some issue'); + done(); + }, + done + ); + }).timeout(60000); + }); +}); diff --git a/src/tests/public-tests.ts b/src/tests/public-tests.ts new file mode 100644 index 0000000..73a7bed --- /dev/null +++ b/src/tests/public-tests.ts @@ -0,0 +1,95 @@ + +import { + BittrexRxClient, + OrderConditionalTypeValue, + TickIntervalValue, + TimeInEffectValue, + MarketOrderValue, + Model +} from '../index' +import * as chai from "chai"; +const assert = chai.assert; + +import { Observable } from 'rxjs'; + + +describe("BitttrexRx Public Methods", () => { + let bittrexRx: BittrexRxClient; + + before(done => { + bittrexRx = new BittrexRxClient(); + done(); + }); + + describe("#getMarkets()", () => { + it("should respond with an instance of Market[]", done => { + bittrexRx.getMarkets() + .subscribe(json => { + assert.instanceOf(json[0], Model.Market); + done(); + }, + done + ); + }).timeout(60000); + }); + + describe("#getTicker()", () => { + it("should respond with an instance of Ticker", done => { + bittrexRx.getTicker('BTC-LTC') + .subscribe(json => { + assert.instanceOf(json, Model.Ticker); + done(); + }, + done + ); + }).timeout(60000); + }); + + describe("#getMarketSummaries()", () => { + it("should respond with an instance of MarketSummary[]", done => { + bittrexRx.getMarketSummaries() + .subscribe(json => { + assert.instanceOf(json[0], Model.MarketSummary); + done(); + }, + done + ); + }).timeout(60000); + }); + + describe("#getOrderBook()", () => { + it("should respond with an instance of OrderBook", done => { + bittrexRx.getOrderBook('BTC-LTC') + .subscribe(json => { + assert.instanceOf(json, Model.OrderBook); + done(); + }, + done + ); + }).timeout(60000); + }); + + describe("#getMarketHistory()", () => { + it("should respond with an instance of MarketHistory", done => { + bittrexRx.getMarketHistory('BTC-LTC') + .subscribe(json => { + assert.instanceOf(json[0], Model.MarketHistory); + done(); + }, + done + ); + }).timeout(60000); + }); + + describe("#getCandles()", () => { + it("should respond with an instance of Candle", done => { + bittrexRx.getCandles('BTC-LTC', TickIntervalValue.Day) + .subscribe(json => { + assert.instanceOf(json[0], Model.Candle); + done(); + }, + done + ); + }).timeout(60000); + }); +});