WIP fix broken tests

This commit is contained in:
Katrina Uychaco
2017-08-25 19:58:51 -07:00
parent 7c3fe7dba4
commit 1dc5dec816
2 changed files with 34 additions and 10 deletions

View File

@@ -899,12 +899,15 @@ describe "Config", ->
previousSetTimeoutCallCount = setTimeout.callCount
runs ->
fs.writeFileSync(atom.config.configFilePath, data)
waitsFor "debounced config file load", ->
setTimeout.callCount > previousSetTimeoutCallCount
# waitsFor "debounced config file load", ->
# setTimeout.callCount > previousSetTimeoutCallCount
waitsFor "file written", ->
fs.readFileSync(atom.config.configFilePath, 'utf8') is data
runs ->
advanceClock(1000)
beforeEach ->
console.log 'beforeEach'
atom.config.setSchema 'foo',
type: 'object'
properties:
@@ -930,16 +933,28 @@ describe "Config", ->
scoped: true
"""
atom.config.loadUserConfig()
atom.config.observeUserConfig()
updatedHandler = jasmine.createSpy("updatedHandler")
atom.config.onDidChange updatedHandler
console.log 'observeUserConfig promise', atom.config.observeUserConfig()
waitsForPromise -> atom.config.observeUserConfig()
runs ->
updatedHandler = jasmine.createSpy("updatedHandler")
atom.config.onDidChange updatedHandler
afterEach ->
# WHY IS THIS NOT RUNNING?
console.log 'afterEach'
atom.config.unobserveUserConfig()
fs.removeSync(dotAtomPath)
describe "when the config file changes to contain valid cson", ->
it "updates the config data", ->
afterEach ->
# WHY IS THIS NOT RUNNING?
console.log 'afterEach'
atom.config.unobserveUserConfig()
fs.removeSync(dotAtomPath)
fit "updates the config data", ->
writeConfigFile("foo: { bar: 'quux', baz: 'bar'}")
waitsFor 'update event', -> updatedHandler.callCount > 0
runs ->

View File

@@ -849,6 +849,7 @@ class Config
loadUserConfig: ->
return if @shouldNotAccessFileSystem()
console.log 'loadUserConfig'
try
unless fs.existsSync(@configFilePath)
fs.makeTreeSync(path.dirname(@configFilePath))
@@ -880,9 +881,14 @@ class Config
return if @shouldNotAccessFileSystem()
try
@watchSubscription ?= watchPath @configFilePath, {}, (events) =>
console.trace 'create watch subscription', @watchSubscriptionPromise
@watchSubscriptionPromise ?= watchPath @configFilePath, {}, (events) =>
console.log events
for {action} in events
@requestLoad() if action in ['created', 'modified', 'renamed'] and @watchSubscription?
console.log action, @watchSubscriptionPromise?
if action in ['created', 'modified', 'renamed'] and @watchSubscriptionPromise?
console.warn 'request load'
@requestLoad()
catch error
@notifyFailure """
Unable to watch path: `#{path.basename(@configFilePath)}`. Make sure you have permissions to
@@ -891,9 +897,12 @@ class Config
[watches]:https://github.com/atom/atom/blob/master/docs/build-instructions/linux.md#typeerror-unable-to-watch-path
"""
@watchSubscriptionPromise
unobserveUserConfig: ->
@watchSubscription?.dispose()
@watchSubscription = null
@watchSubscriptionPromise?.then((watcher) => watcher?.dispose())
@watchSubscriptionPromise = null
console.log 'unobserve'
notifyFailure: (errorMessage, detail) ->
@notificationManager?.addError(errorMessage, {detail, dismissable: true})