sendou.ink/app/modules/plus-server/voting-time.test.ts
2022-06-11 11:49:22 +03:00

29 lines
738 B
TypeScript

import { suite } from "uvu";
import * as assert from "uvu/assert";
import { lastCompletedVoting } from "./voting-time";
const LastCompletedVoting = suite("lastCompletedVoting()");
LastCompletedVoting("Previous month if voting yet to happen", () => {
assert.equal(lastCompletedVoting(new Date(Date.UTC(2022, 4, 1))), {
month: 3,
year: 2022,
});
});
LastCompletedVoting("Previous month if voting in progress", () => {
assert.equal(lastCompletedVoting(new Date(Date.UTC(2022, 4, 7))), {
month: 3,
year: 2022,
});
});
LastCompletedVoting("Same month if voting over", () => {
assert.equal(lastCompletedVoting(new Date(Date.UTC(2022, 4, 15))), {
month: 4,
year: 2022,
});
});
LastCompletedVoting.run();