* init Signed-off-by: Innei <i@innei.in> * chore: utils import Signed-off-by: Innei <tukon479@gmail.com> * remove stable router Signed-off-by: Innei <tukon479@gmail.com> * refactor: components import Signed-off-by: Innei <tukon479@gmail.com> * chore: auto-fix linting and formatting issues * minify Signed-off-by: Innei <tukon479@gmail.com> * update Signed-off-by: Innei <tukon479@gmail.com> * fix: test Signed-off-by: Innei <tukon479@gmail.com> * chore: ui component extract Signed-off-by: Innei <tukon479@gmail.com> * fix: import Signed-off-by: Innei <tukon479@gmail.com> * re-render Signed-off-by: Innei <tukon479@gmail.com> * refactor: remove hooks Signed-off-by: Innei <tukon479@gmail.com> * fix Signed-off-by: Innei <tukon479@gmail.com> * update Signed-off-by: Innei <tukon479@gmail.com> * setting Signed-off-by: Innei <tukon479@gmail.com> * update Signed-off-by: Innei <tukon479@gmail.com> * refactor: remove icons Signed-off-by: Innei <i@innei.in> * typings Signed-off-by: Innei <i@innei.in> * feat: add horizontal scroll functionality to TimelineTabs (#1081) Co-authored-by: xhuajin <xhuajin@users.noreply.github.com> Co-authored-by: Stephen Zhou <38493346+hyoban@users.noreply.github.com> * fix: Wrong initial position of tab animation (#1087) Co-authored-by: hamster1963 <hamster1963@users.noreply.github.com> * fix: disable auto toggle readability in web * fix: margin condition in EntryListHeader (#1103) * chore(i18n): add daily reward system translation (#1102) Co-authored-by: lc4t <lc4t@users.noreply.github.com> * fix: deps Signed-off-by: Innei <i@innei.in> * fix: type Signed-off-by: Innei <i@innei.in> * update Signed-off-by: Innei <i@innei.in> * fix Signed-off-by: Innei <i@innei.in> --------- Signed-off-by: Innei <i@innei.in> Signed-off-by: Innei <tukon479@gmail.com> Co-authored-by: Innei <Innei@users.noreply.github.com> Co-authored-by: Huajin <114134574+xhuajin@users.noreply.github.com> Co-authored-by: xhuajin <xhuajin@users.noreply.github.com> Co-authored-by: Stephen Zhou <38493346+hyoban@users.noreply.github.com> Co-authored-by: 仓鼠 <71394853+hamster1963@users.noreply.github.com> Co-authored-by: hamster1963 <hamster1963@users.noreply.github.com> Co-authored-by: Konv Suu <2583695112@qq.com> Co-authored-by: lc4t <11334449+lc4t@users.noreply.github.com> Co-authored-by: lc4t <lc4t@users.noreply.github.com>
73 lines
2.1 KiB
TypeScript
73 lines
2.1 KiB
TypeScript
import { sleep } from "@follow/utils/utils"
|
|
import { beforeAll, beforeEach, describe, expect, test } from "vitest"
|
|
|
|
import { browserDB } from "~/database"
|
|
import { entryActions } from "~/store/entry/store"
|
|
|
|
import mockEntiresData from "./__mock__data__/entries.json"
|
|
import { EntryService } from "./entry"
|
|
import { EntryRelatedKey, EntryRelatedService } from "./entry-related"
|
|
|
|
const deleteIds = ["46871301655897088", "46871301655897090"]
|
|
|
|
describe.concurrent("Entry Service", () => {
|
|
beforeAll(async () => {
|
|
await browserDB.delete()
|
|
})
|
|
beforeEach(async () => {
|
|
await browserDB.open()
|
|
entryActions.upsertMany(mockEntiresData as any[])
|
|
await sleep(1)
|
|
})
|
|
|
|
test.sequential("assert data is ready", async () => {
|
|
const data = await EntryService.findAll()
|
|
const ids = data.map((d) => d.id)
|
|
expect(ids).toMatchInlineSnapshot(`
|
|
[
|
|
"46871301655897088",
|
|
"46871301655897089",
|
|
"46871301655897090",
|
|
"46877798792098816",
|
|
]
|
|
`)
|
|
const readMap = await EntryRelatedService.findAll(EntryRelatedKey.READ)
|
|
expect(readMap).toMatchInlineSnapshot(`
|
|
{
|
|
"46871301655897088": true,
|
|
"46871301655897089": true,
|
|
"46871301655897090": true,
|
|
"46877798792098816": true,
|
|
}
|
|
`)
|
|
})
|
|
test.sequential("delete entry", async () => {
|
|
await EntryService.deleteEntries(deleteIds)
|
|
const readMap = await EntryRelatedService.findAll(EntryRelatedKey.READ)
|
|
expect(readMap).toMatchInlineSnapshot(`
|
|
{
|
|
"46871301655897089": true,
|
|
"46877798792098816": true,
|
|
}
|
|
`)
|
|
const ret = await EntryService.findAll()
|
|
expect(ret.map((d) => d.id)).not.toContain(deleteIds)
|
|
})
|
|
|
|
test.sequential("delete by feed id ", async () => {
|
|
await EntryService.deleteEntriesByFeedIds(["41397633064960000"])
|
|
const ret = await EntryService.findAll()
|
|
expect(ret.map((d) => d.id)).toMatchInlineSnapshot(`
|
|
[
|
|
"46877798792098816",
|
|
]
|
|
`)
|
|
const readMap = await EntryRelatedService.findAll(EntryRelatedKey.READ)
|
|
expect(readMap).toMatchInlineSnapshot(`
|
|
{
|
|
"46877798792098816": true,
|
|
}
|
|
`)
|
|
})
|
|
})
|