mirror of
https://github.com/pulsar-edit/pulsar.git
synced 2024-09-20 07:28:08 +03:00
Add better errors to .toHaveLength spec exception
Returns a helpful error when the actual object does not have a length var.
This commit is contained in:
parent
2876618218
commit
c90eb7fc73
@ -118,9 +118,13 @@ addCustomMatchers = (spec) ->
|
|||||||
@actual instanceof expected
|
@actual instanceof expected
|
||||||
|
|
||||||
toHaveLength: (expected) ->
|
toHaveLength: (expected) ->
|
||||||
notText = if @isNot then " not" else ""
|
if not @actual?
|
||||||
this.message = => "Expected object with length #{@actual.length} to#{notText} have length #{expected}"
|
this.message = => "Expected object #{@actual} has no length method"
|
||||||
@actual.length == expected
|
false
|
||||||
|
else
|
||||||
|
notText = if @isNot then " not" else ""
|
||||||
|
this.message = => "Expected object with length #{@actual.length} to#{notText} have length #{expected}"
|
||||||
|
@actual.length == expected
|
||||||
|
|
||||||
toExistOnDisk: (expected) ->
|
toExistOnDisk: (expected) ->
|
||||||
notText = this.isNot and " not" or ""
|
notText = this.isNot and " not" or ""
|
||||||
|
Loading…
Reference in New Issue
Block a user