diff --git a/chai-immutable.js b/chai-immutable.js index eee10e1..7a42985 100644 --- a/chai-immutable.js +++ b/chai-immutable.js @@ -24,6 +24,13 @@ var Assertion = chai.Assertion; + function assertIsIterable(obj) { + new Assertion(obj).assert( + Immutable.Iterable.isIterable(obj), + 'expected #{this} to be an Iterable' + ); + } + /** * ## BDD API Reference */ @@ -309,7 +316,7 @@ */ function assertCollectionSize(n) { - new Assertion(this._obj).instanceof(Collection); + assertIsIterable(this._obj); var size = this._obj.size; new Assertion(size).a('number'); @@ -335,7 +342,7 @@ function assertCollectionSizeLeast(_super) { return function (n) { if (utils.flag(this, 'immutable.collection.size')) { - new Assertion(this._obj).instanceof(Collection); + assertIsIterable(this._obj); var size = this._obj.size; new Assertion(size).a('number'); @@ -355,7 +362,7 @@ function assertCollectionSizeMost(_super) { return function (n) { if (utils.flag(this, 'immutable.collection.size')) { - new Assertion(this._obj).instanceof(Collection); + assertIsIterable(this._obj); var size = this._obj.size; new Assertion(size).a('number'); @@ -375,7 +382,7 @@ function assertCollectionSizeAbove(_super) { return function (n) { if (utils.flag(this, 'immutable.collection.size')) { - new Assertion(this._obj).instanceof(Collection); + assertIsIterable(this._obj); var size = this._obj.size; new Assertion(size).a('number'); @@ -395,7 +402,7 @@ function assertCollectionSizeBelow(_super) { return function (n) { if (utils.flag(this, 'immutable.collection.size')) { - new Assertion(this._obj).instanceof(Collection); + assertIsIterable(this._obj); var size = this._obj.size; new Assertion(size).a('number'); @@ -429,7 +436,7 @@ Assertion.overwriteMethod('within', function (_super) { return function (min, max) { if (utils.flag(this, 'immutable.collection.size')) { - new Assertion(this._obj).instanceof(Collection); + assertIsIterable(this._obj); var size = this._obj.size; new Assertion(size).a('number');