Clear font style in afterEach so it doesn't cause test pollution

This commit is contained in:
Nathan Sobo
2013-02-09 16:47:00 -07:00
parent 13db9169e9
commit 97988eb62e
2 changed files with 10 additions and 4 deletions

View File

@@ -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 }

View File

@@ -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