-
Notifications
You must be signed in to change notification settings - Fork 8.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: pgayvallet <pierre.gayvallet@elastic.co>
- Loading branch information
1 parent
5f63498
commit b360cb7
Showing
26 changed files
with
328 additions
and
138 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
20 changes: 11 additions & 9 deletions
20
src/core/public/overlays/__snapshots__/modal.test.tsx.snap
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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
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
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
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,62 @@ | ||
/* | ||
* Licensed to Elasticsearch B.V. under one or more contributor | ||
* license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright | ||
* ownership. Elasticsearch B.V. licenses this file to you under | ||
* the Apache License, Version 2.0 (the "License"); you may | ||
* not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
|
||
import React from 'react'; | ||
import { mount } from 'enzyme'; | ||
import { MountWrapper, mountForComponent } from './utils'; | ||
|
||
describe('MountWrapper', () => { | ||
it('renders an html element in react tree', () => { | ||
const mountPoint = (container: HTMLElement) => { | ||
const el = document.createElement('p'); | ||
el.textContent = 'hello'; | ||
el.className = 'bar'; | ||
container.append(el); | ||
return () => {}; | ||
}; | ||
const wrapper = <MountWrapper mount={mountPoint} />; | ||
const container = mount(wrapper); | ||
expect(container.html()).toMatchInlineSnapshot(`"<div><p class=\\"bar\\">hello</p></div>"`); | ||
}); | ||
|
||
it('updates the react tree when the mounted element changes', () => { | ||
const el = document.createElement('p'); | ||
el.textContent = 'initial'; | ||
|
||
const mountPoint = (container: HTMLElement) => { | ||
container.append(el); | ||
return () => {}; | ||
}; | ||
|
||
const wrapper = <MountWrapper mount={mountPoint} />; | ||
const container = mount(wrapper); | ||
expect(container.html()).toMatchInlineSnapshot(`"<div><p>initial</p></div>"`); | ||
|
||
el.textContent = 'changed'; | ||
container.update(); | ||
expect(container.html()).toMatchInlineSnapshot(`"<div><p>changed</p></div>"`); | ||
}); | ||
|
||
it('can render a detached react component', () => { | ||
const mountPoint = mountForComponent(<span>detached</span>); | ||
const wrapper = <MountWrapper mount={mountPoint} />; | ||
const container = mount(wrapper); | ||
expect(container.html()).toMatchInlineSnapshot(`"<div><span>detached</span></div>"`); | ||
}); | ||
}); |
Oops, something went wrong.