Skip to content
This repository has been archived by the owner on Oct 1, 2024. It is now read-only.

Use outerHTML for html() on DOM nodes #1042

Merged
merged 4 commits into from
Sep 30, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/react-hydrate/src/test/e2e.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ describe('react-hydrate', () => {
);

expect(clientHydrator.find('div')).toHaveReactProps({
dangerouslySetInnerHTML: {__html: serverHydrator.find('div')!.html()},
dangerouslySetInnerHTML: {__html: content},
});
});
});
2 changes: 2 additions & 0 deletions packages/react-testing/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ and adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).

<!-- ## [Unreleased] -->

- Fixed `html()` to properly return the outermost wrapping DOM tags ([#1042](https://github.com/Shopify/quilt/pull/1042))

## [1.7.9] - 2019-09-27

### Changed
Expand Down
2 changes: 1 addition & 1 deletion packages/react-testing/src/element.ts
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ export class Element<Props> implements Node<Props> {
}

if (instance instanceof HTMLElement) {
return instance.innerHTML;
return instance.outerHTML;
}

return allChildren.reduce<string>(
Expand Down
4 changes: 2 additions & 2 deletions packages/react-testing/src/tests/element.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ describe('Element', () => {
});

describe('#html()', () => {
it('returns the innerHTML of the element if it is a DOM node', () => {
it('returns the outerHTML of the element if it is a DOM node', () => {
const html = 'foobar';

const div = document.createElement('div');
Expand All @@ -303,7 +303,7 @@ describe('Element', () => {
defaultRoot,
);

expect(element.html()).toBe(html);
expect(element.html()).toBe(`<div>${html}</div>`);
});

it('concatenates the HTML contents of all child elements and child text', () => {
Expand Down