Skip to content

Commit

Permalink
settings.defaultResultOptions now extended properly
Browse files Browse the repository at this point in the history
  • Loading branch information
mdb committed Feb 19, 2013
1 parent 09ad796 commit b0c7081
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 7 deletions.
4 changes: 4 additions & 0 deletions lib/archaeologist.js
Expand Up @@ -18,6 +18,10 @@ function Archaeologist(opts) {
};

this.settings = opts ? _.defaults(opts, this.defaultSettings) : this.defaultSettings;

if (opts && opts.defaultResultOptions) {
this.settings.defaultResultOptions = _.defaults(opts.defaultResultOptions, this.defaultSettings.defaultResultOptions);
}
}

Archaeologist.prototype.get = function (params, callback) {
Expand Down
38 changes: 31 additions & 7 deletions test/archaeologist.js
Expand Up @@ -29,19 +29,43 @@ describe("Archaeologist", function() {
});
});

it("can be overridden on instantiation", function () {
it("can be extended on instantiation", function () {
var arcInst = new Archaeologist({
apiHost: 'http://fakehost.com',
apiPathBase: '/fake/path',
defaultResultOptions: {
foo: 'bar',
baz: 'bim'
}
apiPathBase: '/fake/path'
});

expect(arcInst.settings.apiHost).to.eql('http://fakehost.com');
expect(arcInst.settings.apiPathBase).to.eql('/fake/path');
expect(arcInst.settings.defaultResultOptions).to.eql({foo: 'bar', baz: 'bim'});
});

describe("#defaultResultOptions", function () {
it("exists as a property on 'settings'", function () {
var arcInst = new Archaeologist({
apiHost: 'http://fakehost.com',
apiPathBase: '/fake/path',
defaultResultOptions: {
foo: 'bar',
baz: 'bim'
}
});
expect(typeof arc.settings.defaultResultOptions).to.eql('object');
});

it("can be extended on instantiation", function () {
var arcInst = new Archaeologist({
apiHost: 'http://fakehost.com',
apiPathBase: '/fake/path',
defaultResultOptions: {
foo: 'bar',
baz: 'bim'
}
});

expect(arcInst.settings.defaultResultOptions.foo).to.eql('bar');
expect(arcInst.settings.defaultResultOptions.baz).to.eql('bim');
expect(arcInst.settings.defaultResultOptions.f).to.eql('json');
});
});
});

Expand Down

0 comments on commit b0c7081

Please sign in to comment.