Skip to content

Commit

Permalink
Revert "Support searching for a plain text string in to contain"
Browse files Browse the repository at this point in the history
This reverts commit d586657.
  • Loading branch information
sunesimonsen committed Feb 26, 2019
1 parent 8ea580c commit 7d4a20f
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 20 deletions.
8 changes: 1 addition & 7 deletions documentation/assertions/DOMElement/to-contain.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,7 @@ string:
expect(element, 'to contain', '<h1>Assert on text content</h1>');
```

You can also assert that the element contains a given text node:

```js
expect(element, 'to contain', 'Assert on text content');
```

Or you can also assert against a DOM element:
You can also assert against a DOM element:

```js
expect(element, 'to contain', createElement('<h1>Assert on text content</h1>'));
Expand Down
16 changes: 8 additions & 8 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -1651,15 +1651,15 @@ module.exports = {
);

if (typeof spec === 'string') {
spec = {
textContent: spec
};
} else {
ensureSupportedSpecOptions(spec);

expect.argsOutput = output =>
output.appendInspected(documentFragment.childNodes[0]);
throw new Error(
'HTMLElement to contain string: please provide a HTML structure as a string'
);
}

expect.argsOutput = output =>
output.appendInspected(documentFragment.childNodes[0]);

ensureSupportedSpecOptions(spec);
}

const scoredElements = findMatchesWithGoodScore(nodes, spec);
Expand Down
16 changes: 11 additions & 5 deletions test/index.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -3158,12 +3158,18 @@ describe('unexpected-dom', () => {
);
});

it('supports searching for a plain string', () => {
it('fails searching for a plain string', () => {
expect(
'<div><span class="greeting"><span>Hello</span><span class="name">Jane Doe</span></span></div>',
'when parsed as HTML',
'to contain',
'Jane Doe'
() => {
expect(
'<div><span class="greeting"><span>Hello</span><span class="name">Jane Doe</span></span></div>',
'when parsed as HTML',
'to contain',
'Jane Doe'
);
},
'to throw',
'HTMLElement to contain string: please provide a HTML structure as a string'
);
});

Expand Down

0 comments on commit 7d4a20f

Please sign in to comment.