Fix another two tests

This commit is contained in:
Damien Guard 2017-09-06 15:28:58 -07:00
parent af66c5efaa
commit 468f4a47a9
No known key found for this signature in database
GPG Key ID: DC14FA2FB1465DB6
2 changed files with 19 additions and 20 deletions

View File

@ -1375,7 +1375,8 @@ describe "PackageManager", ->
atom.themes.activateThemes()
afterEach ->
atom.themes.deactivateThemes()
waitsForPromise ->
atom.themes.deactivateThemes()
it "enables and disables a theme", ->
packageName = 'theme-with-package-file'

View File

@ -262,27 +262,25 @@ class ThemeManager
new Promise (resolve) =>
# @config.observe runs the callback once, then on subsequent changes.
@config.observe 'core.themes', =>
@deactivateThemes()
@deactivateThemes().then =>
@warnForNonExistentThemes()
@refreshLessCache() # Update cache for packages in core.themes config
@warnForNonExistentThemes()
promises = []
for themeName in @getEnabledThemeNames()
if @packageManager.resolvePackagePath(themeName)
promises.push(@packageManager.activatePackage(themeName))
else
console.warn("Failed to activate theme '#{themeName}' because it isn't installed.")
@refreshLessCache() # Update cache for packages in core.themes config
promises = []
for themeName in @getEnabledThemeNames()
if @packageManager.resolvePackagePath(themeName)
promises.push(@packageManager.activatePackage(themeName))
else
console.warn("Failed to activate theme '#{themeName}' because it isn't installed.")
Promise.all(promises).then =>
@addActiveThemeClasses()
@refreshLessCache() # Update cache again now that @getActiveThemes() is populated
@loadUserStylesheet()
@reloadBaseStylesheets()
@initialLoadComplete = true
@emitter.emit 'did-change-active-themes'
resolve()
Promise.all(promises).then =>
@addActiveThemeClasses()
@refreshLessCache() # Update cache again now that @getActiveThemes() is populated
@loadUserStylesheet()
@reloadBaseStylesheets()
@initialLoadComplete = true
@emitter.emit 'did-change-active-themes'
resolve()
deactivateThemes: ->
@removeActiveThemeClasses()