Sha256: 68d423c954c61c276911be21c446b131c69775120f5905dee8cc9fa0352726cb

Contents?: true

Size: 1.72 KB

Versions: 30

Compression:

Stored size: 1.72 KB

Contents

"use strict";

var assert      = require("chai").assert
  , isArrayLike = require("../../array-like/is");

describe("array-like/is", function () {
	it("Should return true on array", function () { assert.equal(isArrayLike([]), true); });
	it("Should return true on array-like object", function () {
		assert.equal(isArrayLike({ length: 1 }), true);
	});
	it("Should by default return false on string", function () {
		assert.equal(isArrayLike("foo"), false);
	});
	it("Should accept strings if specified", function () {
		assert.equal(isArrayLike("foo", { allowString: true }), true);
	});

	it("Should return false on objects with negative length", function () {
		assert.equal(isArrayLike({ length: -1 }), false);
	});

	it("Should return false on plain object", function () {
		assert.equal(isArrayLike({}), false);
	});
	it("Should return false on function", function () {
		assert.equal(isArrayLike(function () { return true; }), false);
	});

	if (typeof Object.create === "function") {
		it("Should return false on object with no prototype", function () {
			assert.equal(isArrayLike(Object.create(null)), false);
		});
	}
	it("Should return false on number", function () { assert.equal(isArrayLike(123), false); });
	it("Should return false on NaN", function () { assert.equal(isArrayLike(NaN), false); });
	it("Should return false on boolean", function () { assert.equal(isArrayLike(true), false); });
	if (typeof Symbol === "function") {
		it("Should return false on symbol", function () {
			assert.equal(isArrayLike(Symbol("foo")), false);
		});
	}

	it("Should return false on null", function () { assert.equal(isArrayLike(null), false); });
	it("Should return false on undefined", function () {
		assert.equal(isArrayLike(void 0), false);
	});
});

Version data entries

30 entries across 29 versions & 2 rubygems

Version Path
optimacms-0.1.61 spec/dummy/node_modules/ext/node_modules/type/test/array-like/is.js
optimacms-0.1.61 spec/dummy/node_modules/type/test/array-like/is.js
govuk_publishing_components-18.0.0 node_modules/type/test/array-like/is.js
govuk_publishing_components-17.21.0 node_modules/type/test/array-like/is.js
govuk_publishing_components-17.20.0 node_modules/type/test/array-like/is.js
govuk_publishing_components-17.19.1 node_modules/type/test/array-like/is.js
govuk_publishing_components-17.19.0 node_modules/type/test/array-like/is.js
govuk_publishing_components-17.18.0 node_modules/type/test/array-like/is.js
govuk_publishing_components-17.17.0 node_modules/type/test/array-like/is.js
govuk_publishing_components-17.16.0 node_modules/type/test/array-like/is.js
govuk_publishing_components-17.15.0 node_modules/type/test/array-like/is.js
govuk_publishing_components-17.14.0 node_modules/type/test/array-like/is.js
govuk_publishing_components-17.13.0 node_modules/type/test/array-like/is.js
govuk_publishing_components-17.12.2 node_modules/type/test/array-like/is.js
govuk_publishing_components-17.12.1 node_modules/type/test/array-like/is.js
govuk_publishing_components-17.12.0 node_modules/type/test/array-like/is.js
govuk_publishing_components-17.11.0 node_modules/type/test/array-like/is.js
govuk_publishing_components-17.10.0 node_modules/type/test/array-like/is.js
govuk_publishing_components-17.9.0 node_modules/type/test/array-like/is.js
govuk_publishing_components-17.8.0 node_modules/type/test/array-like/is.js