-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: update package versions and add trimAnnStartEndToFitSeqLength …
…utility function with tests, start to add protein editor test
- Loading branch information
Showing
9 changed files
with
108 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
export default function trimAnnStartEndToFitSeqLength( | ||
annStartOrEnd, | ||
sequenceLength | ||
) { | ||
return Math.max( | ||
0, | ||
Math.min(annStartOrEnd || 0, Math.max(sequenceLength - 1, 0)) | ||
); | ||
} |
35 changes: 35 additions & 0 deletions
35
packages/range-utils/src/trimAnnStartEndToFitSeqLength.test.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import trimAnnStartEndToFitSeqLength from "./trimAnnStartEndToFitSeqLength"; | ||
|
||
describe("trimAnnStartEndToFitSeqLength", () => { | ||
test("should return 0 if annStartOrEnd is undefined", () => { | ||
expect(trimAnnStartEndToFitSeqLength(undefined, 10)).toBe(0); | ||
}); | ||
|
||
test("should return 0 if annStartOrEnd is null", () => { | ||
expect(trimAnnStartEndToFitSeqLength(null, 10)).toBe(0); | ||
}); | ||
|
||
test("should return 0 if annStartOrEnd is less than 0", () => { | ||
expect(trimAnnStartEndToFitSeqLength(-5, 10)).toBe(0); | ||
}); | ||
|
||
test("should return annStartOrEnd if it is within the sequence length", () => { | ||
expect(trimAnnStartEndToFitSeqLength(5, 10)).toBe(5); | ||
}); | ||
|
||
test("should return sequenceLength - 1 if annStartOrEnd is greater than sequenceLength", () => { | ||
expect(trimAnnStartEndToFitSeqLength(15, 10)).toBe(9); | ||
}); | ||
|
||
test("should return 0 if sequenceLength is 0", () => { | ||
expect(trimAnnStartEndToFitSeqLength(5, 0)).toBe(0); | ||
}); | ||
|
||
test("should return 0 if sequenceLength is negative", () => { | ||
expect(trimAnnStartEndToFitSeqLength(5, -10)).toBe(0); | ||
}); | ||
|
||
test("should return 0 if annStartOrEnd is 0", () => { | ||
expect(trimAnnStartEndToFitSeqLength(0, 10)).toBe(0); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters