Skip to content

Commit

Permalink
fix: Merge pull request #138 from pelias/add-support-for-wof-supersed…
Browse files Browse the repository at this point in the history
…ed-by-field

switched from `edtf:superseded` to `wof:superseded_by`
  • Loading branch information
orangejulius authored Oct 4, 2016
2 parents b0564bf + 0542218 commit fe3f0ef
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 11 deletions.
4 changes: 3 additions & 1 deletion src/components/isActiveRecord.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ function isDeprecated(wofData) {
}

function isSuperseded(wofData) {
return !_.isEmpty(_.trim(wofData.properties['edtf:superseded']));
return wofData.properties.hasOwnProperty('wof:superseded_by') &&
_.isArray(wofData.properties['wof:superseded_by']) &&
wofData.properties['wof:superseded_by'].length > 0;
}

function isCurrent(wofData) {
Expand Down
20 changes: 10 additions & 10 deletions test/components/isActiveRecordTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,16 +30,16 @@ tape('isActiveRecord', function(test) {

});

test.test('undefined/blank edtf:superseded values should return true', function(t) {
test.test('undefined/non-array/zero-length wof:superseded_by should return true', function(t) {
var input = [
{ properties: { 'edtf:superseded': undefined } },
{ properties: { 'edtf:superseded': '' } },
{ properties: { 'edtf:superseded': ' \t ' } }
{ properties: { 'wof:superseded_by': undefined } },
{ properties: { 'wof:superseded_by': 'this is not an array' } },
{ properties: { 'wof:superseded_by': [] } }
];
var expected = [
{ properties: { 'edtf:superseded': undefined } },
{ properties: { 'edtf:superseded': '' } },
{ properties: { 'edtf:superseded': ' \t ' } }
{ properties: { 'wof:superseded_by': undefined } },
{ properties: { 'wof:superseded_by': 'this is not an array' } },
{ properties: { 'wof:superseded_by': [] } }
];

test_stream(input, isActiveRecord.create(), function(err, actual) {
Expand All @@ -49,7 +49,7 @@ tape('isActiveRecord', function(test) {

});

test.test('properties without edtf:superseded or edtf:deprecated or mz:is_current should return true', function(t) {
test.test('properties without wof:superseded_by or edtf:deprecated or mz:is_current should return true', function(t) {
var input = [
{ properties: { } }
];
Expand Down Expand Up @@ -77,9 +77,9 @@ tape('isActiveRecord', function(test) {

});

test.test('non-blank edtf:superseded values should return false', function(t) {
test.test('non-zero-length wof:superseded_by array should return false', function(t) {
var input = [
{ properties: { 'edtf:superseded': 'some value' } }
{ properties: { 'wof:superseded_by': [1, 2] } }
];
var expected = [];

Expand Down

0 comments on commit fe3f0ef

Please sign in to comment.