         themeManager.activateThemes()
 
       runs ->
+        atom.styles.onDidRemoveStyleElement styleElementRemovedHandler = jasmine.createSpy("styleElementRemovedHandler")
+        atom.styles.onDidAddStyleElement styleElementAddedHandler = jasmine.createSpy("styleElementAddedHandler")
+
         themeManager.onDidChangeStylesheets stylesheetsChangedHandler = jasmine.createSpy("stylesheetsChangedHandler")
         themeManager.onDidRemoveStylesheet stylesheetRemovedHandler = jasmine.createSpy("stylesheetRemovedHandler")
         themeManager.onDidAddStylesheet stylesheetAddedHandler = jasmine.createSpy("stylesheetAddedHandler")

      runs ->
        expect($(document.body).css('border-style')).toBe 'dashed'

        expect(stylesheetRemovedHandler).toHaveBeenCalled()
        expect(stylesheetRemovedHandler.argsForCall[0][0].cssRules[0].style.border).toBe 'dotted'

        expect(stylesheetAddedHandler).toHaveBeenCalled()
        expect(stylesheetAddedHandler.argsForCall[0][0].cssRules[0].style.border).toBe 'dashed'

        expect(stylesheetsChangedHandler).toHaveBeenCalled()

        stylesheetRemovedHandler.reset()
        stylesheetsChangedHandler.reset()
        fs.removeSync(userStylesheetPath)

          expect(workspaceElement).not.toHaveClass 'theme-atom-dark-syntax'

  describe "when the user stylesheet changes", ->
    beforeEach ->
      jasmine.snapshotDeprecations()

    afterEach ->
      jasmine.restoreDeprecationsSnapshot()

    it "reloads it", ->
      [styleElementAddedHandler, styleElementRemovedHandler] = []
      [stylesheetRemovedHandler, stylesheetAddedHandler, stylesheetsChangedHandler] = []
      userStylesheetPath = path.join(temp.mkdirSync("atom"), 'styles.less')
      fs.writeFileSync(userStylesheetPath, 'body {border-style: dotted !important;}')
