Skip to content

Commit

Permalink
test: supplement
Browse files Browse the repository at this point in the history
  • Loading branch information
letwebdev committed Feb 28, 2024
1 parent 73eaf08 commit 00beb60
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/libs/__test__/formatter.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { test, expect } from "vitest"
import { convertUnixTimeStampToReadableTime } from "../formatter"

test("test", () => {
const time = convertUnixTimeStampToReadableTime(1709112255)
expect(time).toBe("2024-02-28 17:24")
})
11 changes: 11 additions & 0 deletions src/libs/__test__/math.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { generateRandomInteger } from "../math"

for (let i = 0; i < 5; i++) {
test("generate random integer", () => {
expect(generateRandomInteger(5, 1)).toBeLessThanOrEqual(5)
expect(generateRandomInteger(5, 1)).toBeGreaterThanOrEqual(1)

expect(generateRandomInteger(7, 2)).toBeLessThanOrEqual(7)
expect(generateRandomInteger(5, 2)).toBeGreaterThanOrEqual(2)
})
}
17 changes: 17 additions & 0 deletions src/stores/__test__/settings.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { useSettingsStore } from "../settings"

describe("Settings Store", () => {
beforeEach(() => {
// creates a fresh pinia and makes it active
// so it's automatically picked up by any useStore() call
// without having to pass it to it: `useStore(pinia)`
setActivePinia(createPinia())
})

it("reset setting", () => {
const store = useSettingsStore()
store.settings.displayingItemId.value = false
store.settingOperations.reset()
expect(store.settings.displayingItemId.value).toBeTruthy()
})
})

0 comments on commit 00beb60

Please sign in to comment.