Skip to content

Commit

Permalink
v2.2.1; fix #93
Browse files Browse the repository at this point in the history
  • Loading branch information
justincy committed Apr 23, 2015
1 parent ddc0c7f commit 3ab71d6
Show file tree
Hide file tree
Showing 5 changed files with 65 additions and 25 deletions.
5 changes: 4 additions & 1 deletion fs-check.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,16 @@ module.exports = {
});
};

// If we don't have a birth
if(!birth || !birth.date) {
return;
}

var birthFormal = utils.getFormalDate(birth);

if(!birthFormal){
return;
}

for(var i = 0; i < parents.length; i++){
var parentBirth = parents[i].$getBirth();
if(parentBirth){
Expand Down
2 changes: 1 addition & 1 deletion fs-check.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion fs-check.min.js.map

Large diffs are not rendered by default.

5 changes: 4 additions & 1 deletion lib/checks/birthBeforeParentsBirth.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,16 @@ module.exports = {
});
};

// If we don't have a birth
if(!birth || !birth.date) {
return;
}

var birthFormal = utils.getFormalDate(birth);

if(!birthFormal){
return;
}

for(var i = 0; i < parents.length; i++){
var parentBirth = parents[i].$getBirth();
if(parentBirth){
Expand Down
76 changes: 55 additions & 21 deletions test/checks/birthBeforeParentsBirth.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,47 @@ describe('birthBeforeParentsBirth', function(){
facts: [
FS.createFact({
type: 'http://gedcomx.org/Birth',
place: 'Provo, Utah, United States of America'
$place: 'Provo, Utah, United States of America'
})
]
});
var opportunity = fsCheck.check(person, []);
expect(opportunity).to.equal(undefined);
});

it('should return nothing when the birth date has no extractable formal value for comparison', function(){
var person = FS.createPerson({
gender: 'http://gedcomx.org/Female',
names: [],
facts: [
FS.createFact({
type: 'http://gedcomx.org/Birth',
$place: 'Provo, Utah, United States of America',
$date: 'Oct 6th'
})
]
});
var opportunity = fsCheck.check(person, [
FS.createPerson({
gender: 'http://gedcomx.org/Male',
names: [
FS.createName({
givenName: 'Bob',
surname: 'Freemer'
})
],
facts: [
FS.createFact({
type: 'http://gedcomx.org/Birth',
$date: 'January 1, 1895',
$formalDate: '+1895-01-01',
$place: 'Provo, Utah, United States of America'
})
]
})
]);
expect(opportunity).to.equal(undefined);
});

it('should return nothing when there are no parents', function() {
var person = FS.createPerson({
Expand All @@ -38,9 +72,9 @@ describe('birthBeforeParentsBirth', function(){
facts: [
FS.createFact({
type: 'http://gedcomx.org/Birth',
date: 'January 1, 1900',
formalDate: '+1900-01-01',
place: 'Provo, Utah, United States of America'
$date: 'January 1, 1900',
$formalDate: '+1900-01-01',
$place: 'Provo, Utah, United States of America'
})
]
});
Expand All @@ -55,9 +89,9 @@ describe('birthBeforeParentsBirth', function(){
facts: [
FS.createFact({
type: 'http://gedcomx.org/Birth',
date: 'January 1, 1920',
formalDate: '+1920-01-01',
place: 'Provo, Utah, United States of America'
$date: 'January 1, 1920',
$formalDate: '+1920-01-01',
$place: 'Provo, Utah, United States of America'
})
]
});
Expand All @@ -68,7 +102,7 @@ describe('birthBeforeParentsBirth', function(){
facts: [
FS.createFact({
type: 'http://gedcomx.org/Birth',
place: 'Provo, Utah, United States of America'
$place: 'Provo, Utah, United States of America'
})
]
})
Expand All @@ -87,9 +121,9 @@ describe('birthBeforeParentsBirth', function(){
facts: [
FS.createFact({
type: 'http://gedcomx.org/Birth',
date: 'May 1, 1920',
formalDate: '+1920-05-01',
place: 'Provo, Utah, United States of America'
$date: 'May 1, 1920',
$formalDate: '+1920-05-01',
$place: 'Provo, Utah, United States of America'
})
]
});
Expand All @@ -99,33 +133,33 @@ describe('birthBeforeParentsBirth', function(){
gender: 'http://gedcomx.org/Female',
names: [
FS.createName({
givenName: 'Thelma',
surname: 'Louise'
$givenName: 'Thelma',
$surname: 'Louise'
})
],
facts: [
FS.createFact({
type: 'http://gedcomx.org/Birth',
date: 'January 1, 1920',
formalDate: '+1920-01-01',
place: 'Provo, Utah, United States of America'
$date: 'January 1, 1920',
$formalDate: '+1920-01-01',
$place: 'Provo, Utah, United States of America'
})
]
}),
FS.createPerson({
gender: 'http://gedcomx.org/Male',
names: [
FS.createName({
givenName: 'Bob',
surname: 'Freemer'
$givenName: 'Bob',
$surname: 'Freemer'
})
],
facts: [
FS.createFact({
type: 'http://gedcomx.org/Birth',
date: 'January 1, 1895',
formalDate: '+1895-01-01',
place: 'Provo, Utah, United States of America'
$date: 'January 1, 1895',
$formalDate: '+1895-01-01',
$place: 'Provo, Utah, United States of America'
})
]
})
Expand Down

0 comments on commit 3ab71d6

Please sign in to comment.