-
-
Notifications
You must be signed in to change notification settings - Fork 8k
/
docusaurusContext.test.tsx
44 lines (42 loc) · 1.5 KB
/
docusaurusContext.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
/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @jest-environment jsdom
*/
// Jest doesn't allow pragma below other comments. https://github.com/facebook/jest/issues/12573
// eslint-disable-next-line header/header
import React from 'react';
// TODO migrate to @testing-library/react when SSR rendering possible
// See https://github.com/testing-library/react-testing-library/issues/1120
import {renderHook} from '@testing-library/react-hooks/server';
import {DocusaurusContextProvider} from '../docusaurusContext';
import useDocusaurusContext from '../exports/useDocusaurusContext';
// This test currently isn't quite useful because the @generated aliases point
// to the empty modules. Maybe we can point that to fixtures in the future.
describe('DocusaurusContextProvider', () => {
const {result, hydrate} = renderHook(() => useDocusaurusContext(), {
wrapper: ({children}) => (
<DocusaurusContextProvider>{children}</DocusaurusContextProvider>
),
});
const value = result.current;
it('returns right value', () => {
expect(value).toMatchInlineSnapshot(`
{
"codeTranslations": {},
"globalData": {},
"i18n": {},
"siteConfig": {},
"siteMetadata": {},
"themeConfig": {},
}
`);
});
it('has reference-equal value on hydration', () => {
hydrate();
expect(result.current).toBe(value);
});
});