Skip to content

Commit

Permalink
💚 24時間以内に交流したユーザを判定するテストを追加
Browse files Browse the repository at this point in the history
  • Loading branch information
dicenull committed Sep 3, 2024
1 parent 47910e0 commit ad98bab
Show file tree
Hide file tree
Showing 2 changed files with 63 additions and 3 deletions.
35 changes: 34 additions & 1 deletion deno.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

31 changes: 29 additions & 2 deletions tests/distilled_user_test.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,32 @@
import { assertEquals } from "https://deno.land/std@0.224.0/assert/mod.ts";
import { distilledUserWithin24Hours } from "../library/distilled_user_within_24hour.js";
import { getNowTime } from "../library/get_time.js";

Deno.test("デモテスト", () => {
assertEquals(1 + 1, 2);
Deno.test("24時間以内に交流したユーザだけ取得できる", async () => {
const request = new Request("https://example.com/?id=1");
const user1 = {
key: ["SP", 1, 2],
value: {
User: 2,
time: getNowTime(),
},
};
const user2 = {
key: ["SP", 2, 3],
value: {
User: 3,
time: getNowTime(),
},
};
const kv = {
list: async function* () {
yield user1;
yield user2;
},
};

const response = await distilledUserWithin24Hours(request, kv);

const data = await response.json();
assertEquals(data, [user1]);
});

0 comments on commit ad98bab

Please sign in to comment.