Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test(stackflow): Add id/time Test Code #405

Merged
merged 6 commits into from
Aug 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions core/src/utils/id.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { id } from "./id";

beforeAll(() => {
jest.useFakeTimers();
});

test("id - 시간을 기반으로 유니크한 아이디 값을 반환한다.", () => {
jest.setSystemTime(new Date("2023-08-07T09:00:00Z"));

const id1 = id();
const id2 = id();

expect(id1).not.toBe(id2);
});
14 changes: 14 additions & 0 deletions core/src/utils/time.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { time } from "./time";

beforeAll(() => {
jest.useFakeTimers();
});

test("time - 동일한 시간에 여러번 호출될 경우 중복을 방지한다.", () => {
jest.setSystemTime(new Date("2023-08-07T09:00:00Z"));

const time1 = time();
const time2 = time();

expect(time1).not.toBe(time2);
});
Loading