Skip to content

Commit

Permalink
Use Iterable.isIterable for Immutable check
Browse files Browse the repository at this point in the history
  • Loading branch information
jakelazaroff committed Dec 12, 2015
1 parent 6a9c9ed commit b34220f
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions chai-immutable.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@

var Assertion = chai.Assertion;

function isImmutable(obj) {
return Immutable.Iterable.isIterable(obj);
}

/**
* ## BDD API Reference
*/
Expand All @@ -46,7 +50,7 @@
return function () {
var obj = this._obj;

if (obj && obj instanceof Collection) {
if (isImmutable(obj)) {
var size = obj.size;
new Assertion(size).a('number');

Expand Down Expand Up @@ -96,7 +100,7 @@
return function (collection) {
var obj = this._obj;

if (obj && obj instanceof Collection) {
if (isImmutable(obj)) {
this.assert(
Immutable.is(obj, collection),
'expected #{act} to equal #{exp}',
Expand Down Expand Up @@ -141,7 +145,7 @@
return function (val) {
var obj = this._obj;

if (obj && obj instanceof Collection) {
if (isImmutable(obj)) {
this.assert(
obj.includes(val),
'expected #{act} to include #{exp}',
Expand Down

0 comments on commit b34220f

Please sign in to comment.