mirror of
https://github.com/atom/atom.git
synced 2026-04-28 03:01:47 -04:00
WIP fix broken tests
This commit is contained in:
@@ -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 ->
|
||||
|
||||
@@ -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})
|
||||
|
||||
Reference in New Issue
Block a user