Skip to content

Commit

Permalink
[skyapi] refs fibercrypto#12 - Modify nodejs api client tester
Browse files Browse the repository at this point in the history
  • Loading branch information
stdevCbermudez committed Apr 17, 2019
1 parent 9dcdad6 commit c941fc9
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 22 deletions.
34 changes: 34 additions & 0 deletions tests/config.js
Original file line number Diff line number Diff line change
@@ -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();
32 changes: 10 additions & 22 deletions tests/node/test/node.js
Original file line number Diff line number Diff line change
@@ -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');
Expand All @@ -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);

});

0 comments on commit c941fc9

Please sign in to comment.