diff --git a/spec/app/language-mode-spec.coffee b/spec/app/language-mode-spec.coffee index e7bdc7ea9..340f4865c 100644 --- a/spec/app/language-mode-spec.coffee +++ b/spec/app/language-mode-spec.coffee @@ -262,19 +262,19 @@ describe "LanguageMode", -> expect(buffer.lineForRow(0)).toBe "/*body {" expect(buffer.lineForRow(1)).toBe " font-size: 1234px;*/" expect(buffer.lineForRow(2)).toBe " width: 110%;" - expect(buffer.lineForRow(3)).toBe "}" + expect(buffer.lineForRow(3)).toBe " font-weight: bold !important;" languageMode.toggleLineCommentsForBufferRows(2, 2) expect(buffer.lineForRow(0)).toBe "/*body {" expect(buffer.lineForRow(1)).toBe " font-size: 1234px;*/" expect(buffer.lineForRow(2)).toBe "/* width: 110%;*/" - expect(buffer.lineForRow(3)).toBe "}" + expect(buffer.lineForRow(3)).toBe " font-weight: bold !important;" languageMode.toggleLineCommentsForBufferRows(0, 1) expect(buffer.lineForRow(0)).toBe "body {" expect(buffer.lineForRow(1)).toBe " font-size: 1234px;" expect(buffer.lineForRow(2)).toBe "/* width: 110%;*/" - expect(buffer.lineForRow(3)).toBe "}" + expect(buffer.lineForRow(3)).toBe " font-weight: bold !important;" it "uncomments lines with leading whitespace", -> buffer.replaceLines(2, 2, " /*width: 110%;*/") diff --git a/spec/app/window-spec.coffee b/spec/app/window-spec.coffee index 05e582d34..9cd9103b2 100644 --- a/spec/app/window-spec.coffee +++ b/spec/app/window-spec.coffee @@ -48,6 +48,16 @@ describe "Window", -> requireStylesheet('atom.css') expect($('head style').length).toBe lengthBefore + 1 + describe ".disableStyleSheet(path)", -> + it "removes styling applied by given stylesheet path", -> + cssPath = require.resolve(fs.join("fixtures", "css.css")) + + expect($(document.body).css('font-weight')).not.toBe("bold") + requireStylesheet(cssPath) + expect($(document.body).css('font-weight')).toBe("bold") + removeStylesheet(cssPath) + expect($(document.body).css('font-weight')).not.toBe("bold") + describe "before the window is unloaded", -> it "saves the serialized state of the root view to the atom object so it can be rehydrated after reload", -> expect(atom.getRootViewStateForPath(window.rootView.project.getPath())).toBeUndefined() diff --git a/spec/fixtures/css.css b/spec/fixtures/css.css index 52b8f56c6..d5ae97e68 100644 --- a/spec/fixtures/css.css +++ b/spec/fixtures/css.css @@ -1,4 +1,5 @@ body { font-size: 1234px; width: 110%; + font-weight: bold !important; } diff --git a/src/app/window.coffee b/src/app/window.coffee index 4b6d7047d..5eccba916 100644 --- a/src/app/window.coffee +++ b/src/app/window.coffee @@ -65,9 +65,14 @@ windowAdditions = requireStylesheet: (path) -> unless fullPath = require.resolve(path) - throw new Error("requireStylesheet could not find a file at path '#{path}'") + throw new Error("Could not find a file at path '#{path}'") window.applyStylesheet(fullPath, fs.read(fullPath)) + removeStylesheet: (path) -> + unless fullPath = require.resolve(path) + throw new Error("Could not find a file at path '#{path}'") + $("head style[id='#{fullPath}']").remove() + applyStylesheet: (id, text) -> unless $("head style[id='#{id}']").length $('head').append ""