Skip to content

Commit

Permalink
Fix #30: Add .notEqual assertion to the TDD API
Browse files Browse the repository at this point in the history
This fixes 2 of the tests failing on #28.
  • Loading branch information
astorije committed Oct 30, 2015
1 parent ebc0499 commit 9930e0e
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 0 deletions.
15 changes: 15 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,21 @@ properly work against `.equal()`, `.strictEqual()` or `.deepEqual()`. See
[this issue](https://github.com/astorije/chai-immutable/issues/24) for
more information.

### .notEqual(actual, expected)

- **@param** *{ Collection }* actual
- **@param** *{ Collection }* expected

Asserts that the values of the target are not equvalent to the values of
`collection`. Note that `.notStrictEqual()` and `.notDeepEqual()` assert
exactly like `.notEqual()` in the context of Immutable data structures.

```js
var a = List.of(1, 2, 3);
var b = List.of(4, 5, 6);
assert.notEqual(a, b);
```

### .sizeOf(collection, length)

- **@param** *{ Collection }* collection
Expand Down
27 changes: 27 additions & 0 deletions chai-immutable.js
Original file line number Diff line number Diff line change
Expand Up @@ -441,6 +441,7 @@

var assert = chai.assert;
var originalEqual = assert.equal;
var originalNotEqual = assert.notEqual;

/**
* ### .equal(actual, expected)
Expand Down Expand Up @@ -477,6 +478,32 @@
else return originalEqual(actual, expected);
};

/**
* ### .notEqual(actual, expected)
*
* Asserts that the values of the target are not equvalent to the values of
* `collection`. Note that `.notStrictEqual()` and `.notDeepEqual()` assert
* exactly like `.notEqual()` in the context of Immutable data structures.
*
* ```js
* var a = List.of(1, 2, 3);
* var b = List.of(4, 5, 6);
* assert.notEqual(a, b);
* ```
*
* @name notEqual
* @param {Collection} actual
* @param {Collection} expected
* @api public
*/

assert.notEqual = function (actual, expected) {
if (actual instanceof Collection) {
return new Assertion(actual).not.equal(expected);
}
else return originalNotEqual(actual, expected);
};

/**
* ### .sizeOf(collection, length)
*
Expand Down

0 comments on commit 9930e0e

Please sign in to comment.