From 97988eb62e354ac529c72cb4a576d01c55db15fe Mon Sep 17 00:00:00 2001 From: Nathan Sobo Date: Sat, 9 Feb 2013 16:47:00 -0700 Subject: [PATCH] Clear font style in afterEach so it doesn't cause test pollution --- spec/app/editor-spec.coffee | 7 +++++-- src/app/editor.coffee | 7 +++++-- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/spec/app/editor-spec.coffee b/spec/app/editor-spec.coffee index c5c5ec6f2..faba56e9f 100644 --- a/spec/app/editor-spec.coffee +++ b/spec/app/editor-spec.coffee @@ -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 } diff --git a/src/app/editor.coffee b/src/app/editor.coffee index 2fd0086ce..5fb06008d 100644 --- a/src/app/editor.coffee +++ b/src/app/editor.coffee @@ -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