# chai-eql-immutable

> Deeply eql for Immutable.js

Latest version **0.0.3** (published 2015-09-27) · MIT license · 0 weekly downloads

## Install

```sh
npm install chai-eql-immutable
pnpm add chai-eql-immutable
yarn add chai-eql-immutable
bun add chai-eql-immutable
```

## Health

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

Positive: no vulnerabilities.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.3 |
| Published | 2015-09-27 |
| First published | 2015-09-27 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 2 |
| Known vulnerabilities | 0 (+1 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 3 |
| Author | hokuma |
| Maintainers | hokuma |
| Keywords | chai, immutable |

## Links

- npm: https://www.npmjs.com/package/chai-eql-immutable
- Repository: https://github.com/hokuma/chai-eql-immutable
- Homepage: https://github.com/hokuma/chai-eql-immutable#readme
- Issues: https://github.com/hokuma/chai-eql-immutable/issues
- npm.io page: https://npm.io/package/chai-eql-immutable

## Dependencies (2)

- [chai](https://npm.io/package/chai.md) ^3.3.0
- [immutable](https://npm.io/package/immutable.md) ^3.7.5

## Alternatives

- [@lexical/table](https://npm.io/package/@lexical/table.md) — 3.0M weekly downloads
- [mantine-datatable](https://npm.io/package/mantine-datatable.md) — 98.2K weekly downloads
- [react-native-collapsible-tab-view](https://npm.io/package/react-native-collapsible-tab-view.md) — 70.6K weekly downloads
- [@handsontable/vue3](https://npm.io/package/@handsontable/vue3.md) — 16.1K weekly downloads
- [vuewordcloud](https://npm.io/package/vuewordcloud.md) — 7.2K weekly downloads

## Recent versions

- 0.0.3 (latest) — 2015-09-27
- 0.0.2 — 2015-09-27
- 0.0.1 — 2015-09-27

## README

# chai-eql-immutable
![build status](https://circleci.com/gh/hokuma/chai-eql-immutable.svg?style=shield&circle-token=c37eec9ee5149ed4e6d1760691258d7cac70b1fa)

This provides a deeply equal assertion for [Facebook's Immutable object](https://facebook.github.io/immutable-js).

# Motivation
Chai `eql` asserts that the target is deeply equal to expected value, including values depending on Immutable objects' innternal state.
It makes diff outsputs complicated like following examples.

```
const a = Immutable.fromJS({a: [{b: 1}]});
const b = Immutable.fromJS({a: [{b: 2}]});
const c = a.setIn('b', 3);

expect(a).to.eql(b);
AssertionError: expected Map { "a": List [ Map { "b": 1 } ] } to deeply equal Map { "a": List [ Map { "b": 2 } ] }
+ expected - actual

                 "_root": {
                   "entries": [
                     [
                       "b"
-                      1
+                      2
                     ]
                   ]
                   "ownerID": {}
                 }

expect(a).to.eql(c);
AssertionError: expected Map { "a": List [ Map { "b": 1 } ] } to deeply equal Map { "a": List [ Map { "b": 3 } ] }
+ expected - actual

                 "_root": {
                   "entries": [
                     [
                       "b"
-                      1
+                      3
               ]
                   ]
-                  "ownerID": {}
+                  "ownerID": [undefined]
                 }
                 "size": 1
               }
             ]
           "size": 1
         }
       ]
     ]
-    "ownerID": {}
+    "ownerID": [undefined]
   }
   "size": 1
 }
```

Immutable has [toJS()](http://facebook.github.io/immutable-js/docs/#/Iterable/toJS) which create equivalent JS object.In this module, if both actual and expected has `toJS()` funciton, calls `toJS()` and asserts with original `eql`. As a result, we can get pretty diff outputs like examples in Usage.

# Usage
```
npm install chai-eql-immutable
```

```
import chai from 'chai';
import chaiEqlImmutable from 'chai-eql-immutable';

chai.use(chaiEqlImmutable);
```

```
//example
const a = Immutable.fromJS({a: [{b: 1}]});
const b = Immutable.fromJS({a: [{b: 1}]});
const c = Immutable.fromJS({a: [{b: 2}]});

expect(a).to.eql(b); // success
expect(a).to.eql(c); // failed
AssertionError: expected { a: [ { b: 1 } ] } to deeply equal { a: [ { b: 2 } ] }
+ expected - actual

{
  "a": [
     {
  -    "b": 1
  +    "b": 2
     }
  ]
}
```

---
_Source: https://npm.io/package/chai-eql-immutable · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
