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 #48

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

ex4 #48

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
12 changes: 11 additions & 1 deletion src/map.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
17 changes: 12 additions & 5 deletions tests/find-a-person.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,17 @@ 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() {
it('Given a person name, return all posts (of a map) containing her name (in any of a post fields)', function() {
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_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"]);
});
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);
});
});