fix script constructor array check
This commit is contained in:
parent
b93a774414
commit
9f2da415ea
2 changed files with 6 additions and 5 deletions
|
@ -6,7 +6,7 @@ var network = require('./network');
|
||||||
|
|
||||||
var Script = function(data) {
|
var Script = function(data) {
|
||||||
this.buffer = data || [];
|
this.buffer = data || [];
|
||||||
if(!Array.isArray(data)) {
|
if(!Array.isArray(this.buffer)) {
|
||||||
throw new Error('expect Script to be initialized with Array, but got ' + data)
|
throw new Error('expect Script to be initialized with Array, but got ' + data)
|
||||||
}
|
}
|
||||||
this.parse();
|
this.parse();
|
||||||
|
|
|
@ -7,11 +7,12 @@ describe('Script', function() {
|
||||||
assert.ok(new Script([]))
|
assert.ok(new Script([]))
|
||||||
})
|
})
|
||||||
|
|
||||||
|
it('works when nothing is passed in', function() {
|
||||||
|
assert.ok(new Script())
|
||||||
|
})
|
||||||
|
|
||||||
it('throws an error when input is not an array', function() {
|
it('throws an error when input is not an array', function() {
|
||||||
assert.throws(function(){
|
assert.throws(function(){ new Script({}) })
|
||||||
new Script({})
|
|
||||||
})
|
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
})
|
})
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue