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

Commit

Permalink
Use outerHTML for html() on DOM nodes (#1042)
Browse files Browse the repository at this point in the history
  • Loading branch information
lemonmade authored Sep 30, 2019
1 parent 36c43bd commit 9ffb958
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 4 deletions.
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

0 comments on commit 9ffb958

Please sign in to comment.