Skip to content

Commit

Permalink
Add view provider registration method on minimap element
Browse files Browse the repository at this point in the history
  • Loading branch information
abe33 committed Dec 14, 2014
1 parent 1caf8c6 commit d1e95aa
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 3 deletions.
12 changes: 11 additions & 1 deletion lib/minimap-element.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,20 @@ class MinimapElement extends HTMLElement
@initializeContent()

attachedCallback: ->

detachedCallback: ->

attributeChangedCallback: (attrName, oldValue, newValue) ->

setModel: (model) ->

initializeContent: ->
@shadowRoot = @createShadowRoot()

module.exports = MinimapElement = document.registerElement 'minimap', prototype: MinimapElement.prototype
module.exports = MinimapElement = document.registerElement 'atom-text-editor-minimap', prototype: MinimapElement.prototype

MinimapElement.registerViewProvider = ->
atom.views.addViewProvider require('./minimap'), (model) ->
element = new MinimapElement
element.setModel(model)
element
26 changes: 24 additions & 2 deletions spec/minimap-element-spec.coffee
Original file line number Diff line number Diff line change
@@ -1,6 +1,28 @@
fs = require 'fs-plus'
{TextEditor} = require 'atom'
Minimap = require '../lib/minimap'
MinimapElement = require '../lib/minimap-element'

describe 'MinimapElement', ->
jasmineContent = null
[editor, minimap, largeSample, smallSample, jasmineContent, editorElement, minimapElement] = []

beforeEach ->
jasmineContent = document.body.querySelector('#jasmine-content')
atom.config.set 'minimap.charHeight', 4
atom.config.set 'minimap.charWidth', 2
atom.config.set 'minimap.interline', 1

MinimapElement.registerViewProvider()

editor = new TextEditor({})
editor.setLineHeightInPixels(10)
editor.setHeight(50)

minimap = new Minimap({textEditor: editor})
largeSample = fs.readFileSync(atom.project.resolve('large-file.coffee')).toString()
smallSample = fs.readFileSync(atom.project.resolve('sample.coffee')).toString()

editorElement = atom.views.getView(editor)
minimapElement = atom.views.getView(minimap)

it 'has been registered in the view registry', ->
expect(minimapElement).toExist()

0 comments on commit d1e95aa

Please sign in to comment.