Skip to content

Commit

Permalink
add support for last uri call, and show failing test for CBOE/VXEEM
Browse files Browse the repository at this point in the history
  • Loading branch information
Victory committed Jan 17, 2016
1 parent 8080570 commit 6d4430d
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 4 deletions.
12 changes: 8 additions & 4 deletions lib/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,9 @@ module.exports = {
var qs = options;
qs.auth_token = this.auth_token;

this.last_uri_called = ["api", this.api_version, "datasets", code.source, code.table].join("/");
var config = {
uri: ["api", this.api_version, "datasets", code.source, code.table].join("/"),
uri: this.last_uri_called,
format: format,
qs: qs,
proxy: this.proxy
Expand Down Expand Up @@ -57,8 +58,9 @@ module.exports = {
return combined_code;
}).join(",");

this.last_uri_called = ["api", this.api_version, "multisets"].join("/");
var config = {
uri: ["api", this.api_version, "multisets"].join("/"),
uri: this.last_uri_called,
format: format,
qs: qs,
proxy: this.proxy
Expand All @@ -79,8 +81,9 @@ module.exports = {
var qs = options;
qs.auth_token = this.auth_token;

this.last_uri_called = ["api", this.api_version, "current_user", "collections", "datasets", "favourites"].join("/");
var config = {
uri: ["api", this.api_version, "current_user", "collections", "datasets", "favourites"].join("/"),
uri: this.last_uri_called,
format: format,
qs: qs,
proxy: this.proxy
Expand All @@ -102,8 +105,9 @@ module.exports = {
qs.auth_token = this.auth_token;
qs.query = terms.replace(" ", "+");

this.last_uri_called = ["api", this.api_version, "datasets"].join("/");
var config = {
uri: ["api", this.api_version, "datasets"].join("/"),
uri: this.last_uri_called,
format: format,
qs: qs,
proxy: this.proxy
Expand Down
1 change: 1 addition & 0 deletions quandl.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ var api = require([__dirname, "lib", "api"].join("/"));

function Quandl(config){
this.configure(config || {});
this.last_uri_called = ""; // contains the string value of the last uri called for debugging and testing, empty if no calls made
}

Quandl.prototype.configure = function(config){
Expand Down
23 changes: 23 additions & 0 deletions test/quandl.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,27 @@ describe("quandl", function(){
});

});


describe("contains last_uri_call", function(){
it("contains an empty string value", function() {
assert.equal(quandl.last_uri_called, "");
});

it("has correct api call for v3", function() {
quandl.configure({
api_version: 3,
auth_token: "dsahFHUiewjjd"
});

quandl.dataset(
{source: 'CBOE/VXEEM', format: 'json'},
function(){});

assert.equal(
quandl.last_uri_called,
"api/v1/datasets/CBOE/VXEEM.json");
});
});

});

0 comments on commit 6d4430d

Please sign in to comment.