forked from sanity-io/next-sanity
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.mjs
50 lines (38 loc) · 1.58 KB
/
test.mjs
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
// Test that exports works when node runs in native ESM mode
import {strict as assert} from 'node:assert'
import {createClient, groq} from 'next-sanity'
// Testing pkg.exports[.]
assert.equal(typeof createClient, 'function')
assert.equal(typeof groq, 'function')
// Testing pkg.exports[./preview]
import {LiveQueryProvider, useLiveQuery} from 'next-sanity/preview'
assert.equal(typeof LiveQueryProvider, 'object')
assert.equal(typeof useLiveQuery, 'function')
// Testing pkg.exports[./studio]
import {
NextStudio,
NextStudioClientOnly,
NextStudioLayout,
NextStudioNoScript,
usePrefersColorScheme,
useTheme,
} from 'next-sanity/studio'
assert.equal(typeof NextStudio?.type, 'function')
assert.equal(typeof NextStudioClientOnly, 'function')
assert.equal(typeof NextStudioLayout?.type, 'function')
assert.equal(typeof NextStudioNoScript, 'function')
assert.equal(typeof usePrefersColorScheme, 'function')
assert.equal(typeof useTheme, 'function')
// Testing pkg.exports[./studio/head]
import {NextStudioHead} from 'next-sanity/studio/head'
assert.equal(typeof NextStudioHead, 'function')
// Testing pkg.exports[./studio/loading]
import {NextStudioLoading} from 'next-sanity/studio/loading'
assert.equal(typeof NextStudioLoading, 'function')
// Testing pkg.exports[./webhook]
import {config, parseBody} from 'next-sanity/webhook'
assert.equal(typeof config, 'object')
assert.equal(typeof parseBody, 'function')
// Ensure it's possible to check what version of next-sanity is being used
import pkg from 'next-sanity/package.json' assert {type: 'json'}
assert.equal(typeof pkg.version, 'string')