-
Notifications
You must be signed in to change notification settings - Fork 844
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[EuiProvider] Fix SSR crashing during new system color mode detection (…
- Loading branch information
Showing
3 changed files
with
37 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
**Bug fixes** | ||
|
||
- Fixed `EuiProvider`'s system color mode detection causing errors during server-side rendering |
29 changes: 29 additions & 0 deletions
29
.../eui/src/components/provider/system_color_mode/system_color_mode_provider.server.test.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
/** | ||
* @jest-environment node | ||
*/ | ||
/* eslint-disable local/require-license-header */ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0 and the Server Side Public License, v 1; you may not use this file except | ||
* in compliance with, at your election, the Elastic License 2.0 or the Server | ||
* Side Public License, v 1. | ||
*/ | ||
|
||
import React from 'react'; | ||
import { renderToString } from 'react-dom/server'; | ||
|
||
import { EuiSystemColorModeProvider } from './system_color_mode_provider'; | ||
|
||
describe('EuiSystemColorModeProvider', () => { | ||
it('handles server-side rendering without crashing', () => { | ||
const children = jest.fn(() => <>Test</>); | ||
|
||
const renderOnServer = () => | ||
renderToString(<EuiSystemColorModeProvider children={children} />); | ||
expect(renderOnServer).not.toThrow(); | ||
|
||
expect(renderOnServer()).toEqual('Test'); | ||
expect(children).toHaveBeenCalledWith('LIGHT'); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters