Skip to content

Commit

Permalink
Stubbed out remainder of hook loading unit tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
mikermcneil committed Jan 4, 2014
1 parent 2c9739a commit b2a7486
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 7 deletions.
24 changes: 18 additions & 6 deletions test/unit/app.initializeHooks.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,14 @@ describe('app.initializeHooks()', function() {



describe('configured with a custom hook called `someCustomHook`', function () {
describe('configured with a custom hook called `noop`', function () {
$Sails.load({
hooks: { someCustomHook: customHooks.NOOP }
hooks: { noop: customHooks.NOOP }
});

it('should expose `someCustomHook`', function () {
it('should expose `noop`', function () {
this.sails.hooks.should.have
.property('someCustomHook');
.property('noop');
});
it('should also expose the expected core hooks', function () {
this.sails.hooks.should.have
Expand All @@ -59,14 +59,26 @@ describe('app.initializeHooks()', function() {



describe('configured with a missing hook dependency', function () {
// $Sails.load();
describe('configured with a hook (`noop2`), but not its dependency (`noop`)', function () {
$Sails.load({
hooks: {
noop2: customHooks.NOOP2
}
});

it('should throw a fatal error');
});



describe('configured with a circular hook dependency', function () {

// NOTE #1: not currently implemented
// NOTE #2: not currently possible
// (should be possible after merging @ragulka's PR)
// $Sails.load();

it('should throw a fatal error');
});


Expand Down
14 changes: 13 additions & 1 deletion test/unit/fixtures/customHooks.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,17 @@
* @type {Object}
*/
module.exports = {
NOOP: function (sails) { return {}; }

// Extremely simple hook that doesn't do anything.
NOOP: function (sails) {
return { identity: 'noop' };
},

// Depends on 'noop' hook
NOOP2: function (sails) {
return {
// TODO: indicate dependency on 'noop' hook
identity: 'noop2'
};
}
};

0 comments on commit b2a7486

Please sign in to comment.