feat: modernize and harden bot deployment
This commit is contained in:
@@ -0,0 +1,19 @@
|
||||
import { assertAlmostEquals, assertThrows } from "@std/assert";
|
||||
import { reactionWeight, scoreForUser, totalScore } from "./scoring.ts";
|
||||
|
||||
Deno.test("one reaction by one user scores one point", () => {
|
||||
assertAlmostEquals(scoreForUser(1), 1);
|
||||
});
|
||||
|
||||
Deno.test("repeat reactions by one user have diminishing weight", () => {
|
||||
assertAlmostEquals(reactionWeight(2), 1 / 3);
|
||||
assertAlmostEquals(scoreForUser(3), 1 + 1 / 3 + 1 / 5);
|
||||
});
|
||||
|
||||
Deno.test("total score sums each user's score", () => {
|
||||
assertAlmostEquals(totalScore([1, 1, 2]), 3 + 1 / 3);
|
||||
});
|
||||
|
||||
Deno.test("invalid reaction counts are rejected", () => {
|
||||
assertThrows(() => scoreForUser(0), RangeError);
|
||||
});
|
||||
Reference in New Issue
Block a user