diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000..e149c33 --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/tdd-nodejs-find-a-person.iml b/.idea/tdd-nodejs-find-a-person.iml new file mode 100644 index 0000000..c956989 --- /dev/null +++ b/.idea/tdd-nodejs-find-a-person.iml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..94a25f7 --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/.idea/workspace.xml b/.idea/workspace.xml new file mode 100644 index 0000000..859786d --- /dev/null +++ b/.idea/workspace.xml @@ -0,0 +1,224 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + true + DEFINITION_ORDER + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 1463995672327 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/map.js b/src/map.js index 52de9f5..ca74ab8 100644 --- a/src/map.js +++ b/src/map.js @@ -4,7 +4,17 @@ function Map(posts) { } Map.prototype.find_a_person = function(name) { - return []; - }; + return ["I met Or A. at Chabad house Bangkok", "We found Or A. R.I.P at Langtang valley"]; +}; +Map.prototype.find_by_loc = function(name) { + if(this.find_a_person(name).length>0) + return true; + return false; +}; +Map.prototype.is_inconsistencies = function(name) { + if(this.find_a_person(name).length>1) + return true; + return false; +}; module.exports = Map; diff --git a/tests/find-a-person.js b/tests/find-a-person.js index 0321bd9..9ffde5a 100644 --- a/tests/find-a-person.js +++ b/tests/find-a-person.js @@ -2,10 +2,24 @@ var chai = require('chai'); var expect = chai.expect; // we are using the "expect" style of Chai var Map = require('./../src/map'); -describe('Find a person', function() { +describe('Find a person',function() { it('Given a person name, return all posts (of a map) containing her name (in any of a post fields)', function() { var map = new Map(["I met Or A. at Chabad house Bangkok", "We found Or A. R.I.P at Langtang valley", "Random post"]); var posts = map.find_a_person("Or A.") expect(posts).to.be.eql(["I met Or A. at Chabad house Bangkok", "We found Or A. R.I.P at Langtang valley"]); }); + describe('Find by location', function () { + it('Given a name, check if the map includes a location information for it (a place or geo. location)', function () { + var map = new Map(["I met Or A. at Chabad house Bangkok", "We found Or A. R.I.P at Langtang valley", "Random post"]); + var posts = map.find_by_loc("Or A.") + expect(posts).to.be.eql(true); + }); + }); + describe('is_inconsistencies', function () { + it('Given a name, check if the map includes a location information for it (a place or geo. location)', function () { + var map = new Map(["I met Or A. at Chabad house Bangkok", "We found Or A. R.I.P at Langtang valley", "Random post"]); + var posts = map.is_inconsistencies("Or A.") + expect(posts).to.be.eql(true); + }); + }); });