-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
6e0866c
commit 8294a00
Showing
2 changed files
with
44 additions
and
9 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,44 @@ | ||
import getMean from "../src/lib/getMean"; | ||
import { FAKE_SESSION } from "../data/FAKE_SESSION"; | ||
|
||
test("Should get the mean from an array of solves", () => { | ||
expect(getMean([])).toBe(0); | ||
expect(getMean([...FAKE_SESSION])).toBe(13658.98076923077); | ||
expect(getMean([...FAKE_SESSION].slice(0, 5))).toBe(13861.6); | ||
expect(getMean([...FAKE_SESSION].slice(5, 12))).toBe(15207.42857142857); | ||
expect(getMean([...FAKE_SESSION].slice(0, 12))).toBe(14646.666666666666); | ||
expect(getMean([...FAKE_SESSION].slice(0, 50))).toBe(13738.22); | ||
expect(getMean()).toBe(0); | ||
describe("Should get the mean from an array of solves", () => { | ||
test("Empty array", () => { | ||
expect(getMean([])).toBe(0); | ||
}); | ||
|
||
test("Full session, undetermined range of values", () => { | ||
expect(getMean([...FAKE_SESSION])).toBe(13658.98076923077); | ||
}); | ||
|
||
test("Session, 5 values", () => { | ||
expect(getMean([...FAKE_SESSION].slice(0, 5))).toBe(13861.6); | ||
}); | ||
|
||
test("Session, 12 values", () => { | ||
expect(getMean([...FAKE_SESSION].slice(0, 12))).toBe(14646.666666666666); | ||
}); | ||
|
||
test("Session, 50 values", () => { | ||
expect(getMean([...FAKE_SESSION].slice(0, 50))).toBe(13738.22); | ||
}); | ||
|
||
test("Empty usage of the function", () => { | ||
expect(getMean()).toBe(0); | ||
}); | ||
|
||
test("Passing a string as parameter", () => { | ||
expect(getMean("string")).toBe(0); | ||
}); | ||
|
||
test("Passing a number as parameter", () => { | ||
expect(getMean(123)).toBe(0); | ||
}); | ||
|
||
test("Passing a null as parameter", () => { | ||
expect(getMean(null)).toBe(0); | ||
}); | ||
|
||
test("Passing a undefined as parameter", () => { | ||
expect(getMean(undefined)).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