Skip to content
This repository has been archived by the owner on Dec 15, 2022. It is now read-only.

Fix fromObject when object is undefined #257

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions spec/range-spec.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@ describe "Range", ->
beforeEach ->
jasmine.addCustomEqualityTester(require("underscore-plus").isEqual)

describe "::fromObject() when object is falsy", ->
it "should not throw", ->
expect(-> Range.fromObject(null)).not.toThrow()
it "should get default values", ->
expect(Range.fromObject(null).toString()).toBe "[(0, 0) - (0, 0)]"

describe "::intersectsWith(other, [exclusive])", ->
intersectsWith = (range1, range2, exclusive) ->
range1 = Range.fromObject(range1)
Expand Down
2 changes: 1 addition & 1 deletion src/range.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class Range
# that are already ranges.˚
#
# Returns: A {Range} based on the given object.
@fromObject: (object, copy) ->
@fromObject: (object = {}, copy) ->
if Array.isArray(object)
new this(object[0], object[1])
else if object instanceof this
Expand Down