/
context.test.ts
45 lines (41 loc) · 1013 Bytes
/
context.test.ts
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
import { describe, it, expect, beforeAll } from 'vitest'
import {
getAllPages,
getCurrentLevelPages,
getPagesUnderRoute
} from '../src/context'
import { collectFiles } from '../src/plugin'
import { CWD } from '../src/constants'
import path from 'node:path'
describe('context', () => {
beforeAll(async () => {
const PAGES_DIR = path.join(
CWD,
'..',
'..',
'examples',
'swr-site',
'pages'
)
const { items } = await collectFiles(PAGES_DIR)
globalThis.__nextra_internal__ = {
pageMap: items,
route: '/docs'
}
})
describe('getAllPages()', () => {
it('should work', () => {
expect(getAllPages()).toMatchSnapshot()
})
})
describe('getCurrentLevelPages()', () => {
it('should work', () => {
expect(getCurrentLevelPages()).toMatchSnapshot()
})
})
describe('getPagesUnderRoute()', () => {
it('should work', () => {
expect(getPagesUnderRoute('/docs/advanced')).toMatchSnapshot()
})
})
})