/
parser-hooks.ts
37 lines (31 loc) · 962 Bytes
/
parser-hooks.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
import { describe, test, expect, assert } from 'vitest'
import { $fetch } from '@nuxt/test-utils'
export const testParserHooks = () => {
describe('parser:hooks', () => {
test('beforeParse', async () => {
const parsed = await $fetch('/api/parse', {
method: 'POST',
body: {
id: 'content:index.md',
content: '# hello'
}
})
expect(parsed).toHaveProperty('_id')
assert(parsed._id === 'content:index.md')
expect(parsed).toHaveProperty('__beforeParse', true)
})
test('afterParse', async () => {
const parsed = await $fetch('/api/parse', {
method: 'POST',
body: {
id: 'content:index.md',
content: '# hello'
}
})
expect(parsed).toHaveProperty('_id')
assert(parsed._id === 'content:index.md')
expect(parsed).haveOwnProperty('body')
expect(parsed).toHaveProperty('__afterParse', true)
})
})
}