diff --git a/chai-immutable.js b/chai-immutable.js index 1adb128..da7e86f 100644 --- a/chai-immutable.js +++ b/chai-immutable.js @@ -24,6 +24,10 @@ var Assertion = chai.Assertion; + function isImmutable(obj) { + return Immutable.Iterable.isIterable(obj); + } + /** * ## BDD API Reference */ @@ -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'); @@ -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}', @@ -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}',