# unexpected-htmllike-jsx-adapter

> Adapter for unexpected-htmllike for ReactElements, e.g. JSX and the shallow renderer

Latest version **1.0.3** (published 2017-09-26) · MIT license · 0 weekly downloads

## Install

```sh
npm install unexpected-htmllike-jsx-adapter
pnpm add unexpected-htmllike-jsx-adapter
yarn add unexpected-htmllike-jsx-adapter
bun add unexpected-htmllike-jsx-adapter
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.3 |
| Published | 2017-09-26 |
| First published | 2015-11-04 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Dave Brotherstone |
| Maintainers | bruderstein |

## Links

- npm: https://www.npmjs.com/package/unexpected-htmllike-jsx-adapter
- Repository: https://github.com/bruderstein/unexpected-htmllike-jsx-adapter
- Homepage: https://github.com/bruderstein/unexpected-htmllike-jsx-adapter#readme
- Issues: https://github.com/bruderstein/unexpected-htmllike-jsx-adapter/issues
- npm.io page: https://npm.io/package/unexpected-htmllike-jsx-adapter

## Dependencies (1)

- [object-assign](https://npm.io/package/object-assign.md) ^4.0.1

## Recent versions

- 1.0.3 (latest) — 2017-09-26
- 1.0.2 — 2017-09-10
- 1.0.1 — 2016-11-13
- 1.0.0 — 2016-04-13
- 0.5.1 — 2016-01-11
- 0.5.0 — 2015-12-21
- 0.4.1 — 2015-12-19
- 0.4.0 — 2015-12-19
- 0.3.0 — 2015-11-07
- 0.2.0 — 2015-11-07
- 0.1.0 — 2015-11-04

## README

# unexpected-htmllike-jsx-adapter

This is the JSX / ReactElement adapter for [unexpected-htmllike](https://github.com/bruderstein/unexpected-htmllike)

# Usage

You need to instantiate a new instance of the adapter in order to use it.  With the instance, you can set
options (using `setOptions({ ... })`) to influence how certain things are returned to 
[unexpected-htmllike](https://github.com/bruderstein/unexpected-htmllike). 

```js
var UnexpectedHtmlLike = require('unexpected-htmllike');
var JsxAdapter = require('unexpected-htmllike-jsx-adapter');

var adapter = new JsxAdapter();

var jsxHtmlLike = new UnexpectedHtmlLike(adapter);

// Now you can use jsxHtmlLike.diff(...) etc

```

# Options

## setOptions(object)

Available options: 
* concatTextContent - (default `false`) set this to true, to concatenate text content items.
* convertToString - (default `false`) converts the content to strings. This is useful when comparing against a rendered
  result, where only strings are available, but you want to maintain the separate items
* convertMultipleRawToStrings - (default: `false`) - converts content to strings, when there is more than one content item.
  This is done specifically for comparing with rendered react elements, where the type is the original for single children,
  but is already converted to a string when there are multiple raw siblings
* includeKeyProp - (default `false`) includes the `key` prop in the returned attributes
* includeRefProp - (default `false`) includse the `ref` prop in the returned attributes

For example, with the following JSX
```xml
<button>
  Button was clicked {this.state.clickCount} times
</button>
```

The `<button>` will have 3 content items:

(Let's say `this.state.clickCount === 10`)

`[ 'Button was clicked ', 10, ' times' ]`

If you're diffing with `unexpected-htmllike`, these 3 content items must match exactly. When setting `concatTextContent` 
to true, this would result in a single string content item

`[ 'Button was clicked 10 times' ]`

If the `convertToString` option is true, the following is returned 

`[ 'Button was clicked ', '10', ' times' ]`

The options take immediate effect, and can be changed per instance of the adapter (hence, you could, although not recommended),
set the options differently for the `actualAdapter` and the `expectedAdapter` for `unexpected-htmllike`

# License

MIT

---
_Source: https://npm.io/package/unexpected-htmllike-jsx-adapter · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
