Last active
September 28, 2016 14:34
-
-
Save sminutoli/2de49febdf55260e508cd47f240c26ec to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
describe('##getItemsGroupedByCategory', ()=> { | |
it('should receive a callback', ()=> { | |
assertFnParams(itemModel.getItemsGroupedByCategory, 1); | |
}); | |
it('should call the callback with the mongoose response', ()=> { | |
let callback = function () {}; | |
mock.schema.aggregate.andReturn(mock.schema); | |
mock.schema.match.andReturn(mock.schema); | |
mock.schema.sort.andReturn(mock.schema); | |
mock.schema.group.andReturn(mock.schema); | |
itemModel.getItemsGroupedByCategory.call(mock, callback); | |
expect(mock.schema.aggregate).toHaveBeenCalled(); | |
expect(mock.schema.match).toHaveBeenCalledWith(itemModel.getMongooseObjects.match.showable); | |
expect(mock.schema.sort).toHaveBeenCalledWith(itemModel.getMongooseObjects.sort.stateType.desc); | |
expect(mock.schema.group).toHaveBeenCalledWith(itemModel.getMongooseObjects.group.categoryId); | |
expect(mock.handleCallback).toHaveBeenCalledWith(callback, httpStatus.BAD_REQUEST); | |
}); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
describe('##getItemsGroupedByCategory', ()=> { | |
//setup | |
let callback = function () {}; | |
mock.schema.aggregate.andReturn(mock.schema); | |
mock.schema.match.andReturn(mock.schema); | |
mock.schema.sort.andReturn(mock.schema); | |
mock.schema.group.andReturn(mock.schema); | |
//action | |
itemModel.getItemsGroupedByCategory.call(mock, callback); | |
it('should receive a callback', ()=> { | |
//assert | |
assertFnParams(itemModel.getItemsGroupedByCategory, 1); | |
}); | |
it('should call the callback aggregate the mongoose response', () => { | |
expect(mock.schema.aggregate).toHaveBeenCalled(); | |
}); | |
it('should call the callback schema.match with match.showable', () => { | |
expect(mock.schema.match).toHaveBeenCalledWith(itemModel.getMongooseObjects.match.showable); | |
}); | |
it('should call the callback schema.match with match.showable', () => { | |
expect(mock.schema.sort).toHaveBeenCalledWith(itemModel.getMongooseObjects.sort.stateType.desc); | |
}); | |
it('should call the callback schema.group with match.showable', () => { | |
expect(mock.schema.group).toHaveBeenCalledWith(itemModel.getMongooseObjects.group.categoryId); | |
}); | |
it('should call the callback handleCallback with match.showable', () => { | |
expect(mock.handleCallback).toHaveBeenCalledWith(callback, httpStatus.BAD_REQUEST); | |
}); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
describe('##getItemsGroupedByCategory', ()=> { | |
let callback; | |
before(() => { | |
callback = function () {}; | |
mock.schema.aggregate.andReturn(mock.schema); | |
mock.schema.match.andReturn(mock.schema); | |
mock.schema.sort.andReturn(mock.schema); | |
mock.schema.group.andReturn(mock.schema); | |
}); | |
it('should receive a callback', ()=> { | |
itemModel.getItemsGroupedByCategory.call(mock, callback); | |
assertFnParams(itemModel.getItemsGroupedByCategory, 1); | |
}); | |
it('should call the callback aggregate the mongoose response', () => { | |
itemModel.getItemsGroupedByCategory.call(mock, callback); | |
expect(mock.schema.aggregate).toHaveBeenCalled(); | |
}); | |
it('should call the callback schema.match with match.showable', () => { | |
itemModel.getItemsGroupedByCategory.call(mock, callback); | |
expect(mock.schema.match).toHaveBeenCalledWith(itemModel.getMongooseObjects.match.showable); | |
}); | |
it('should call the callback schema.match with match.showable', () => { | |
itemModel.getItemsGroupedByCategory.call(mock, callback); | |
expect(mock.schema.sort).toHaveBeenCalledWith(itemModel.getMongooseObjects.sort.stateType.desc); | |
}); | |
it('should call the callback schema.group with match.showable', () => { | |
itemModel.getItemsGroupedByCategory.call(mock, callback); | |
expect(mock.schema.group).toHaveBeenCalledWith(itemModel.getMongooseObjects.group.categoryId); | |
}); | |
it('should call the callback handleCallback with match.showable', () => { | |
itemModel.getItemsGroupedByCategory.call(mock, callback); | |
expect(mock.handleCallback).toHaveBeenCalledWith(callback, httpStatus.BAD_REQUEST); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment