Skip to content

Commit

Permalink
Throw an error when a Minimap is created without TextEditor
Browse files Browse the repository at this point in the history
  • Loading branch information
abe33 committed Dec 14, 2014
1 parent 985616a commit 2c00c80
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
5 changes: 4 additions & 1 deletion lib/minimap.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@ module.exports =
class Minimap
DecorationManagement.includeInto(this)

constructor: ({@textEditor}) ->
constructor: ({@textEditor}={}) ->
unless @textEditor?
throw new Error('Cannot create a minimap without an editor')

@emitter = new Emitter
@subscriptions = subs = new CompositeDisposable
@initializeDecorations()
Expand Down
3 changes: 3 additions & 0 deletions spec/minimap-spec.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ describe 'Minimap', ->
it 'has an associated editor', ->
expect(minimap.getTextEditor()).toEqual(editor)

it 'raise an exceptiono if created without a text editor', ->
expect(-> new Minimap).toThrow()

it 'measures the minimap size based on the current editor content', ->
editor.setText(smallSample)
expect(minimap.getHeight()).toEqual(20)
Expand Down

0 comments on commit 2c00c80

Please sign in to comment.