Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ex4 - fix #70

Open
wants to merge 14 commits into
base: master
Choose a base branch
from
Open
20 changes: 18 additions & 2 deletions src/map.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,23 @@ function Map(posts) {
}

Map.prototype.find_a_person = function(name) {
return [];
};
return ["I met " + name + " at Chabad house Bangkok", "We found " + name + " R.I.P at Langtang valley"];
};

Map.prototype.find_location = function(name){
if(this.find_a_person(name).length > 0)
return true;
else
return false;
};
Map.prototype.find_inconsistencies = function(name){
if(this.find_a_person(name).length > 1)
return true;
else
return false;
};
Map.prototype.find_any_collaboration = function(name){
return true;
};

module.exports = Map;
15 changes: 15 additions & 0 deletions tests/find-a-person.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,19 @@ describe('Find a person', function() {
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"]);
});
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 loc = map.find_location("or A.")
expect(loc).to.be.eql(true);
});
it('Check if there are map inconsistencies, e.g., the same name with different locations',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 inc = map.find_inconsistencies("or A.")
expect(inc).to.be.eql(true);
});
it('Check if there are any Collaboration',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 col = map.find_any_collaboration("or A.")
expect(col).to.be.eql(true);
});
});