Skip to content

Commit

Permalink
Merge pull request #8 from scorpion/develop
Browse files Browse the repository at this point in the history
v1.1.0
  • Loading branch information
brettwilcox authored Sep 30, 2020
2 parents 8e9f037 + cc61b09 commit 81bfc6d
Show file tree
Hide file tree
Showing 5 changed files with 52 additions and 34 deletions.
52 changes: 28 additions & 24 deletions .idea/workspace.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 8 additions & 4 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,11 +80,13 @@ var Scorpion = (function () {

if (args.length === 2) {
// name, factory
return this._register(args[0], args[1]);
this._register(args[0], args[1]);
return this;
}
if (args.length === 3) {
// name, dependencies, factory
return this._register(args[0], args[2], args[1]);
this._register(args[0], args[2], args[1]);
return this;
}
throw new Error('Invalid number of arguments');
}
Expand All @@ -97,11 +99,13 @@ var Scorpion = (function () {

if (args.length === 2) {
// name, factory
return this._register(args[0], args[1], undefined, true);
this._register(args[0], args[1], undefined, true);
return this;
}
if (args.length === 3) {
// name, dependencies, factory
return this._register(args[0], args[2], args[1], true);
this._register(args[0], args[2], args[1], true);
return this;
}
throw new Error('Invalid number of arguments');
}
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,5 +47,5 @@
"prepublish": "npm run bundle",
"test": "mocha --reporter dot --recursive -r setup-referee-sinon/globals test/unit --compilers js:babel/register"
},
"version": "1.0.4"
"version": "1.1.0"
}
12 changes: 8 additions & 4 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,23 +52,27 @@ export default class Scorpion {
register(...args) {
if (args.length === 2) {
// name, factory
return this._register(args[0], args[1]);
this._register(args[0], args[1]);
return this;
}
if (args.length === 3) {
// name, dependencies, factory
return this._register(args[0], args[2], args[1]);
this._register(args[0], args[2], args[1]);
return this;
}
throw new Error('Invalid number of arguments');
}

forceRegister(...args) {
if (args.length === 2) {
// name, factory
return this._register(args[0], args[1], undefined, true);
this._register(args[0], args[1], undefined, true);
return this;
}
if (args.length === 3) {
// name, dependencies, factory
return this._register(args[0], args[2], args[1], true);
this._register(args[0], args[2], args[1], true);
return this;
}
throw new Error('Invalid number of arguments');
}
Expand Down
8 changes: 7 additions & 1 deletion test/unit/index-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ describe('Scorpion', function() {
di.register('foo');
}).toThrow();
});
it('returns the scorpion instance', function() {
expect(di.register('foo', {})).toBe(di);
});
});

describe('forceRegister', function() {
Expand All @@ -32,6 +35,9 @@ describe('Scorpion', function() {
di.forceRegister('foo', {});
}).not.toThrow();
});
it('returns the scorpion instance', function() {
expect(di.forceRegister('foo', {})).toBe(di);
});
});

describe('getResolvedDependencyCount', function() {
Expand Down Expand Up @@ -218,7 +224,7 @@ describe('Scorpion', function() {
di.register('bar', Scorpion.always('bar'));
di.register('foo', ['bar'], Scorpion.once(spy));

return di.get('foo').then(function(bar) {
return di.get('foo').then(function() {
expect(spy).toHaveBeenCalledWith('bar');
});
});
Expand Down

0 comments on commit 81bfc6d

Please sign in to comment.