From 1d374929bfcb4d770217ac6a7640b5d7ed599a87 Mon Sep 17 00:00:00 2001 From: Thomas Rich Date: Tue, 19 Oct 2021 14:11:49 -0700 Subject: [PATCH] fixing tidyUpAnnotation logic and adding a test --- src/tidyUpAnnotation.js | 4 ++-- src/tidyUpSequenceData.test.js | 6 ++++++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/tidyUpAnnotation.js b/src/tidyUpAnnotation.js index d44267e..faa5ece 100644 --- a/src/tidyUpAnnotation.js +++ b/src/tidyUpAnnotation.js @@ -84,8 +84,8 @@ module.exports = function tidyUpAnnotation( if ( !annotation.type || typeof annotation.type !== "string" || - FeatureTypes.some(function(featureType) { - if (featureType.toLowerCase === annotation.type.toLowerCase()) { + !FeatureTypes.some(function(featureType) { + if (featureType.toLowerCase() === annotation.type.toLowerCase()) { annotation.type = featureType; //this makes sure the annotation.type is being set to the exact value of the accepted featureType return true; } diff --git a/src/tidyUpSequenceData.test.js b/src/tidyUpSequenceData.test.js index 94ce7f4..ce9e8d4 100644 --- a/src/tidyUpSequenceData.test.js +++ b/src/tidyUpSequenceData.test.js @@ -217,6 +217,12 @@ describe("tidyUpSequenceData", function() { }); res.features[0].type.should.equal("misc_feature"); }); + it("should add feature type = misc_feature if an invalid type is provided", function() { + const res = tidyUpSequenceData({ + features: [{ start: 4, end: 5, type: "idontexist" }] + }); + res.features[0].type.should.equal("misc_feature"); + }); // it("should normalize strange upper/lower casing in feature types", function() { // const res = tidyUpSequenceData( // {