Skip to content

Commit

Permalink
fix bug caused by sdk bug
Browse files Browse the repository at this point in the history
  • Loading branch information
Justin York committed Jun 18, 2014
1 parent 79ef87a commit e3712cb
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 9 deletions.
13 changes: 9 additions & 4 deletions fs-check.js
Original file line number Diff line number Diff line change
Expand Up @@ -2178,8 +2178,13 @@ module.exports = {
title: 'Possible Duplicate Persons',
signature: 'duplicates',
check: function(person, matches) {

if(matches.getResultsCount() === 0) {

var count = matches.getResultsCount();

// Needs to check for undefined too because of
// https://github.com/rootsdev/familysearch-javascript-sdk/issues/69
// It can be removed when that bug is closed
if(count === 0 || count === undefined) {
return;
}

Expand All @@ -2193,8 +2198,8 @@ module.exports = {
* [Merging duplicate records in Family Tree](https://familysearch.org/ask/productSupport#/Merging-Duplicate-Records-in-Family-Tree-1381814853391)
*/}, {
person: person,
count: matches.getResultsCount(),
people: matches.getResultsCount() === 1 ? 'person' : 'people'
count: count,
people: count === 1 ? 'person' : 'people'
});

return {
Expand Down
13 changes: 9 additions & 4 deletions lib/checks/possibleDuplicates.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,13 @@ module.exports = {
title: 'Possible Duplicate Persons',
signature: 'duplicates',
check: function(person, matches) {

if(matches.getResultsCount() === 0) {

var count = matches.getResultsCount();

// Needs to check for undefined too because of
// https://github.com/rootsdev/familysearch-javascript-sdk/issues/69
// It can be removed when that bug is closed
if(count === 0 || count === undefined) {
return;
}

Expand All @@ -25,8 +30,8 @@ module.exports = {
* [Merging duplicate records in Family Tree](https://familysearch.org/ask/productSupport#/Merging-Duplicate-Records-in-Family-Tree-1381814853391)
*/}, {
person: person,
count: matches.getResultsCount(),
people: matches.getResultsCount() === 1 ? 'person' : 'people'
count: count,
people: count === 1 ? 'person' : 'people'
});

return {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"Family History"
],
"homepage": "https://github.com/genealogysystems/fs-check",
"version": "1.1.0",
"version": "1.1.1",
"repository": {
"type": "git",
"url": "[email protected]:genealogysystems/fs-check.git"
Expand Down
8 changes: 8 additions & 0 deletions test/checks/possibleDuplicates.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,14 @@ describe('possibleDuplicates', function(){
expect(opportunity).to.not.exist;
});

// https://github.com/rootsdev/familysearch-javascript-sdk/issues/69
it('should return nothing when count is undefined', function(){
var matches = {
getResultsCount: function(){}
};
var opportunity = fsCheck.check(new FamilySearch.Person(), matches);
expect(opportunity).to.not.exist;
});

it('should return an opportunity when there are matches', function() {
var person = new FamilySearch.Person();
Expand Down

0 comments on commit e3712cb

Please sign in to comment.