mirror of
https://github.com/atom/atom.git
synced 2026-04-06 03:02:13 -04:00
Clear font style in afterEach so it doesn't cause test pollution
This commit is contained in:
@@ -541,6 +541,9 @@ describe "Editor", ->
|
||||
expect($("head style.font-family")).not.toExist()
|
||||
|
||||
describe "when the font family changes", ->
|
||||
afterEach ->
|
||||
editor.clearFontFamily()
|
||||
|
||||
it "updates the font family on new and existing editors", ->
|
||||
rootView.attachToDom()
|
||||
rootView.height(200)
|
||||
@@ -549,7 +552,7 @@ describe "Editor", ->
|
||||
config.set("editor.fontFamily", "Courier")
|
||||
newEditor = editor.splitRight()
|
||||
|
||||
expect($("head style.font-family").text()).toMatch "{font-family: Courier}"
|
||||
expect($("head style.editor-font-family").text()).toMatch "{font-family: Courier}"
|
||||
expect(editor.css('font-family')).toBe 'Courier'
|
||||
expect(newEditor.css('font-family')).toBe 'Courier'
|
||||
|
||||
@@ -560,7 +563,7 @@ describe "Editor", ->
|
||||
|
||||
lineHeightBefore = editor.lineHeight
|
||||
charWidthBefore = editor.charWidth
|
||||
config.set("editor.fontFamily", "Inconsolata")
|
||||
config.set("editor.fontFamily", "Courier")
|
||||
editor.setCursorScreenPosition [5, 6]
|
||||
expect(editor.charWidth).not.toBe charWidthBefore
|
||||
expect(editor.getCursorView().position()).toEqual { top: 5 * editor.lineHeight, left: 6 * editor.charWidth }
|
||||
|
||||
@@ -742,9 +742,9 @@ class Editor extends View
|
||||
setFontFamily: (fontFamily) ->
|
||||
return if fontFamily == undefined
|
||||
headTag = $("head")
|
||||
styleTag = headTag.find("style.font-family")
|
||||
styleTag = headTag.find("style.editor-font-family")
|
||||
if styleTag.length == 0
|
||||
styleTag = $$ -> @style class: 'font-family'
|
||||
styleTag = $$ -> @style class: 'editor-font-family'
|
||||
headTag.append styleTag
|
||||
|
||||
styleTag.text(".editor {font-family: #{fontFamily}}")
|
||||
@@ -752,6 +752,9 @@ class Editor extends View
|
||||
|
||||
getFontFamily: -> @css("font-family")
|
||||
|
||||
clearFontFamily: ->
|
||||
$('head style.editor-font-family').remove()
|
||||
|
||||
redraw: ->
|
||||
return unless @hasParent()
|
||||
return unless @attached
|
||||
|
||||
Reference in New Issue
Block a user