mirror of
https://github.com/atom/atom.git
synced 2026-02-11 15:14:59 -05:00
Write spec for TextEditorElement when autoHeight changes
This commit is contained in:
@@ -267,6 +267,26 @@ describe "TextEditorElement", ->
|
||||
element.getModel().setMini(false)
|
||||
expect(element.hasAttribute('mini')).toBe false
|
||||
|
||||
describe "on TextEditor::onDidChangeAutoHeight", ->
|
||||
it "changes the element's height", ->
|
||||
element = new TextEditorElement
|
||||
jasmine.attachToDOM(element)
|
||||
expect(element.style.height).toBe('')
|
||||
element.getModel().setAutoHeight(false)
|
||||
|
||||
waitsForPromise ->
|
||||
atom.views.getNextUpdatePromise()
|
||||
|
||||
runs ->
|
||||
expect(element.style.height).toBe('100%')
|
||||
element.getModel().setAutoHeight(true)
|
||||
|
||||
waitsForPromise ->
|
||||
atom.views.getNextUpdatePromise()
|
||||
|
||||
runs ->
|
||||
expect(element.style.height).toBe('')
|
||||
|
||||
describe "events", ->
|
||||
element = null
|
||||
|
||||
|
||||
@@ -38,7 +38,8 @@ class TextEditorElement extends HTMLElement
|
||||
@setAttribute('tabindex', -1)
|
||||
|
||||
initializeContent: (attributes) ->
|
||||
@resetAutoHeight()
|
||||
unless @getModel().getAutoHeight()
|
||||
@style.height = "100%"
|
||||
|
||||
if @config.get('editor.useShadowDOM')
|
||||
@useShadowDOM = true
|
||||
@@ -193,8 +194,11 @@ class TextEditorElement extends HTMLElement
|
||||
@removeAttribute("mini")
|
||||
|
||||
resetAutoHeight: ->
|
||||
unless @getModel().getAutoHeight()
|
||||
@style.height = "100%"
|
||||
@views.updateDocument =>
|
||||
if @getModel().getAutoHeight()
|
||||
@style.height = ""
|
||||
else
|
||||
@style.height = "100%"
|
||||
|
||||
addEncodingAttribute: ->
|
||||
@dataset.encoding = @model.getEncoding()
|
||||
|
||||
Reference in New Issue
Block a user