-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathreader.test.txt
More file actions
80 lines (71 loc) · 2.32 KB
/
Copy pathreader.test.txt
File metadata and controls
80 lines (71 loc) · 2.32 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
import { describe, expect, it } from 'vitest'
import { initAllPage } from '../src/reader'
// import { writeFileSync } from 'node:fs'
// @ts-expect-error __BROWSER__ is defined in rollup options
globalThis.__BROWSER__ = false
describe('renderAllPage', async () => {
it('render alice.epub', async () => {
const pages = await initAllPage(
'./example/alice.epub',
// {
// saveDir: './example',
// }
)
expect(pages.length).toBe(56)
const lastPage = pages[pages.length - 1]
expect(lastPage.chapterId).toBe('item32')
expect(lastPage.pageIndex).toBe(55)
expect(lastPage.svg.length).toBeGreaterThan(10)
expect(lastPage.lastContentIndexOfPage).toBe(309)
})
})
// describe('reader', () => {
// it('alice', async () => {
// const reader = Reader(
// './example/alice.epub',
// )
// const {
// toPrevPage,
// toNextPage,
// getPageIndex,
// getChapterIndex,
// getCurrChapterPageCount,
// } = reader
// const currentPage = await reader.init()
// expect(currentPage.length).toBeGreaterThan(10)
// expect(getPageIndex()).toBe(0)
// expect(getChapterIndex()).toBe(0)
// const prevPage = toPrevPage()
// expect(prevPage).toBe(undefined)
// expect(getPageIndex()).toBe(0)
// expect(getChapterIndex()).toBe(0)
// const nextPage = await toNextPage()
// expect(nextPage).not.toBe(undefined)
// expect(getPageIndex()).toBe(1)
// expect(getChapterIndex()).toBe(0)
// // go to last page of the first chapter
// let lastPage = nextPage
// while (lastPage) {
// lastPage = await toNextPage()
// }
// expect(getPageIndex()).toBe(getCurrChapterPageCount() - 1)
// expect(getChapterIndex()).toBe(0)
// lastPage = await toNextPage()
// expect(lastPage).toBe(undefined)
// expect(getPageIndex()).toBe(getCurrChapterPageCount() - 1)
// expect(getChapterIndex()).toBe(0)
// })
// // it('future', async () => {
// // const reader = Reader(
// // './example/future.epub',
// // )
// // const {
// // toNextPage,
// // } = reader
// // await reader.init()
// // let nextPage = await toNextPage()
// // nextPage = await toNextPage()
// // nextPage = await toNextPage()
// // writeFileSync(`./example/future-0.svg`, nextPage!)
// // })
// })