diff --git a/test/eventApi.test.js b/test/eventApi.test.js index 6ad579d33f..e51c76b986 100644 --- a/test/eventApi.test.js +++ b/test/eventApi.test.js @@ -31,4 +31,11 @@ describe('The event api', function () { .expect(200, done); }); + it('returns events given a name', function (done) { + request + .get('/events/myname') + .expect('Content-Type', /json/) + .expect(200, done); + }); + }); \ No newline at end of file diff --git a/test/eventDbMock.js b/test/eventDbMock.js index b151e19a7d..526505b0a4 100644 --- a/test/eventDbMock.js +++ b/test/eventDbMock.js @@ -25,11 +25,47 @@ var events = [ "type": "feature-create", "created_by": "me", "data": { - "foo": "rab" + "foo": "rab", + "name": "myname" } } ]; +var filterableEvents = [ + { + "id": 1, + "created_at": 1414159948677, + "type": "feature-create", + "created_by": "me", + "data": { + "name": "foo" + } + }, + { + "id": 2, + "created_at": 1414159948677, + "type": "feature-create", + "created_by": "me", + "data": { + "name": "bar" + } + }, + { + "id": 3, + "created_at": 1414159948677, + "type": "feature-create", + "created_by": "me", + "data": { + "name": "myname" + } + } +]; + + +function filterEventsByName(name) { + return filterableEvents.filter(function (n){return n.data.name===name;}); +} + function getEvent(name) { var eventFound; events.forEach(function (event) { @@ -57,6 +93,12 @@ module.exports = { }); }, + getEventsFilterByName: function(name) { + return new Promise(function (resolve) { + resolve(filterEventsByName(name)); + }); + }, + getEvent: function(name) { var event = getEvent(name); if(event) { @@ -65,4 +107,5 @@ module.exports = { return Promise.reject("Event not found"); } } + }; \ No newline at end of file