aboutsummaryrefslogtreecommitdiff
path: root/src/client/react/lib/withinRange.test.js
diff options
context:
space:
mode:
Diffstat (limited to 'src/client/react/lib/withinRange.test.js')
-rw-r--r--src/client/react/lib/withinRange.test.js18
1 files changed, 18 insertions, 0 deletions
diff --git a/src/client/react/lib/withinRange.test.js b/src/client/react/lib/withinRange.test.js
new file mode 100644
index 0000000..baec122
--- /dev/null
+++ b/src/client/react/lib/withinRange.test.js
@@ -0,0 +1,18 @@
+import withinRange from './withinRange';
+
+describe('withinRange', () => {
+ describe('the number is within range', () => {
+ it('just returns the number', () => {
+ expect(withinRange(5, 7)).toEqual(5);
+ });
+ });
+
+ describe('the number is outside the range', () => {
+ it('wraps the number until within range', () => {
+ expect(withinRange(-1, 6)).toEqual(6);
+ expect(withinRange(7, 6)).toEqual(0);
+ expect(withinRange(-20, 6)).toEqual(1);
+ expect(withinRange(20, 6)).toEqual(6);
+ });
+ });
+});