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

TDD Assignment #1

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion src/map.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,15 @@ 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_a_location = function(name) {
return true;
};

Map.prototype.find_a_difflocation = function() {
return true;
};

module.exports = Map;
16 changes: 15 additions & 1 deletion tests/find-a-person.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,21 @@ var Map = require('./../src/map');
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.")

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_a_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 diffloc = map.find_a_difflocation();
expect(diffloc).to.be.eql(true);
});
});