 Package = require '../src/package'
 
 describe "ThemeManager", ->
-  themeManager = null
+  [originalThemes, themeManager] = []
   resourcePath = atom.getLoadSettings().resourcePath
   configDirPath = atom.getConfigDirPath()
 
   beforeEach ->
-    themeManager = new ThemeManager({packageManager: atom.packages, resourcePath, configDirPath})
+    originalThemes = atom.themes
+    atom.themes = themeManager = new ThemeManager({packageManager: atom.packages, resourcePath, configDirPath})
 
   afterEach ->
     themeManager.deactivateThemes()
+    atom.themes = originalThemes
 
   describe "theme getters and setters", ->
     beforeEach ->


  describe "when the core.themes config value contains invalid entry", ->
    it "ignores theme", ->
      atom.config.set 'core.themes', [
        'atom-light-ui'
        null

      themes = themeManager.getLoadedThemes()
      expect(themes.length).toBeGreaterThan(2)

    it 'getActiveThemes get all the active themes', ->
      waitsForPromise ->
        themeManager.activateThemes()

