File: test.coffee

package info (click to toggle)
node-is-arrayish 0.3.2-3
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 104 kB
  • sloc: javascript: 8; makefile: 2
file content (22 lines) | stat: -rw-r--r-- 792 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
should = require 'should'
isArrayish = require '../'

Error.stackTraceLimit = Infinity

it 'should check if things are like arrays', ->
  (isArrayish 1).should.equal no
  (isArrayish 'hello').should.equal no
  (isArrayish {}).should.equal no
  (isArrayish null).should.equal no
  (isArrayish undefined).should.equal no

  (isArrayish length: 123, splice: (->)).should.equal yes
  (isArrayish length: 3, 0: 1, 1: 15, 2: 17).should.equal yes
  (isArrayish []).should.equal yes
  (isArrayish __proto__: []).should.equal yes
  (isArrayish __proto__: Array.prototype).should.equal yes
  if Object.setPrototypeOf
    (isArrayish Object.setPrototypeOf {}, []).should.equal yes
    (isArrayish Object.setPrototypeOf {}, Array.prototype).should.equal yes

  (isArrayish [1, 3, 4, 5]).should.equal yes