diff --git a/tests/config.js b/tests/config.js new file mode 100644 index 0000000..d85ae78 --- /dev/null +++ b/tests/config.js @@ -0,0 +1,34 @@ +let host = process.env.HOST; +let port = process.env.PORT; +let user = { + username: process.env.WEB_USERNAME, + password: process.env.WEB_PASSWORD +}; + +let set_defaults = function () { + if (host === undefined) { + if (port === undefined) { + port = 6420; + } + host = `http://localhost:${port}`; + } + + if (user.username === undefined) { + user.username = 'foobar'; + } + + if (user.password === undefined) { + user.password = 'abcdef123'; + } +}; + +let set_exports = function () { + exports.HOST = host; + exports.PORT = port; + exports.WEB_USERNAME = user.username; + exports.WEB_PASSWORD = user.password; +}; + +set_defaults(); + +set_exports(); diff --git a/tests/node/test/node.js b/tests/node/test/node.js index 469cc7d..6099cc1 100644 --- a/tests/node/test/node.js +++ b/tests/node/test/node.js @@ -1,19 +1,14 @@ "use strict"; -const localBasePath = 'http://localhost:6420/'; -const developBasePath = 'https://staging.node.skycoin.net'; -const prodBasePath = 'https://node.skycoin.net'; +const config = require('../../config'); let nodeClient = require('libsky-node'); var expect = require('chai').expect; -describe('#nodeClient', function() { - - this.timeout(10000); - - context(`Getting version from ${developBasePath}.`, function() { +const checkVersion = function (path) { + context(`Getting version from ${path}.`, function() { it('Should return version object', function() { - let api = new nodeClient.DefaultApi(developBasePath); + let api = new nodeClient.DefaultApi(path); return api.version().then(result => { expect(result).to.be.a('object'); expect(result).to.have.property('body'); @@ -24,19 +19,12 @@ describe('#nodeClient', function() { }); }); }); +}; - context(`Getting version from ${prodBasePath}.`, function() { - it('Should return version object', function() { - let api = new nodeClient.DefaultApi(prodBasePath); - return api.version().then(result => { - expect(result).to.be.a('object'); - expect(result).to.have.property('body'); - expect(result.body).to.be.a('object'); - expect(result.body).to.have.property('version'); - expect(result.body).to.have.property('commit'); - expect(result.body).to.have.property('branch'); - }); - }); - }); +describe('#nodeClient', function() { + + this.timeout(10000); + + checkVersion(config.HOST); });