-
Notifications
You must be signed in to change notification settings - Fork 394
/
StudioProvider.test.tsx
52 lines (41 loc) · 1.19 KB
/
StudioProvider.test.tsx
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
import React, {useEffect} from 'react'
import {render, act} from '@testing-library/react'
import {createConfig} from '../../config'
import {StudioProvider} from '../StudioProvider'
import {useWorkspace} from '../workspace'
describe('StudioProvider', () => {
it('works', async () => {
const consoleErrorSpy = jest.spyOn(console, 'error').mockImplementation(() => {
// intentionally blank
})
const projectId = 'ppsg7ml5'
window.localStorage.setItem(
`__studio_auth_token_${projectId}`,
JSON.stringify({
token: 'skaQT9YgcOZEKweP9PCUzQH3SoEYBGjudmJp4MwTBw8TlTIGPVWtDWDLKbJRxCCHcFrt5s4sTxZHcQCh',
})
)
const config = createConfig({
name: 'default',
projectId,
dataset: 'test',
})
function Content() {
const workspace = useWorkspace()
useEffect(() => {
// console.log({workspace})
}, [workspace])
return <>content!</>
}
const {debug} = render(
<StudioProvider config={config}>
<Content />
</StudioProvider>
)
await act(async () => {
await new Promise((resolve) => setTimeout(resolve, 1000))
})
debug()
consoleErrorSpy.mockRestore()
})
})