diff --git a/spec/config-spec.coffee b/spec/config-spec.coffee index cf0726384..7d1dd98d4 100644 --- a/spec/config-spec.coffee +++ b/spec/config-spec.coffee @@ -1,5 +1,4 @@ -fs = require 'fs' -fsUtils = require 'fs-utils' +{fs} = require 'atom-api' path = require 'path' CSON = require 'season' @@ -162,10 +161,10 @@ describe "Config", -> describe ".initializeConfigDirectory()", -> beforeEach -> config.configDirPath = '/tmp/dot-atom-dir' - expect(fsUtils.exists(config.configDirPath)).toBeFalsy() + expect(fs.exists(config.configDirPath)).toBeFalsy() afterEach -> - fsUtils.remove('/tmp/dot-atom-dir') if fsUtils.exists('/tmp/dot-atom-dir') + fs.remove('/tmp/dot-atom-dir') if fs.exists('/tmp/dot-atom-dir') describe "when the configDirPath doesn't exist", -> it "copies the contents of dot-atom to ~/.atom", -> @@ -177,24 +176,24 @@ describe "Config", -> waitsFor -> initializationDone runs -> - expect(fsUtils.exists(config.configDirPath)).toBeTruthy() - expect(fsUtils.exists(path.join(config.configDirPath, 'packages'))).toBeTruthy() - expect(fsUtils.exists(path.join(config.configDirPath, 'snippets'))).toBeTruthy() - expect(fsUtils.exists(path.join(config.configDirPath, 'themes'))).toBeTruthy() - expect(fsUtils.isFileSync(path.join(config.configDirPath, 'config.cson'))).toBeTruthy() + expect(fs.exists(config.configDirPath)).toBeTruthy() + expect(fs.exists(path.join(config.configDirPath, 'packages'))).toBeTruthy() + expect(fs.exists(path.join(config.configDirPath, 'snippets'))).toBeTruthy() + expect(fs.exists(path.join(config.configDirPath, 'themes'))).toBeTruthy() + expect(fs.isFileSync(path.join(config.configDirPath, 'config.cson'))).toBeTruthy() describe ".loadUserConfig()", -> beforeEach -> config.configDirPath = '/tmp/dot-atom-dir' config.configFilePath = path.join(config.configDirPath, "config.cson") - expect(fsUtils.exists(config.configDirPath)).toBeFalsy() + expect(fs.exists(config.configDirPath)).toBeFalsy() afterEach -> - fsUtils.remove('/tmp/dot-atom-dir') if fsUtils.exists('/tmp/dot-atom-dir') + fs.remove('/tmp/dot-atom-dir') if fs.exists('/tmp/dot-atom-dir') describe "when the config file contains valid cson", -> beforeEach -> - fsUtils.writeSync(config.configFilePath, "foo: bar: 'baz'") + fs.writeSync(config.configFilePath, "foo: bar: 'baz'") config.loadUserConfig() it "updates the config data based on the file contents", -> @@ -203,7 +202,7 @@ describe "Config", -> describe "when the config file contains invalid cson", -> beforeEach -> spyOn(console, 'error') - fsUtils.writeSync(config.configFilePath, "{{{{{") + fs.writeSync(config.configFilePath, "{{{{{") it "logs an error to the console and does not overwrite the config file on a subsequent save", -> config.loadUserConfig() @@ -213,9 +212,9 @@ describe "Config", -> describe "when the config file does not exist", -> it "creates it with an empty object", -> - fsUtils.makeTree(config.configDirPath) + fs.makeTree(config.configDirPath) config.loadUserConfig() - expect(fsUtils.exists(config.configFilePath)).toBe true + expect(fs.exists(config.configFilePath)).toBe true expect(CSON.readFileSync(config.configFilePath)).toEqual {} describe ".observeUserConfig()", -> @@ -224,8 +223,8 @@ describe "Config", -> beforeEach -> config.configDirPath = '/tmp/dot-atom-dir' config.configFilePath = path.join(config.configDirPath, "config.cson") - expect(fsUtils.exists(config.configDirPath)).toBeFalsy() - fsUtils.writeSync(config.configFilePath, "foo: bar: 'baz'") + expect(fs.exists(config.configDirPath)).toBeFalsy() + fs.writeSync(config.configFilePath, "foo: bar: 'baz'") config.loadUserConfig() config.observeUserConfig() updatedHandler = jasmine.createSpy("updatedHandler") @@ -233,11 +232,11 @@ describe "Config", -> afterEach -> config.unobserveUserConfig() - fsUtils.remove('/tmp/dot-atom-dir') if fsUtils.exists('/tmp/dot-atom-dir') + fs.remove('/tmp/dot-atom-dir') if fs.exists('/tmp/dot-atom-dir') describe "when the config file changes to contain valid cson", -> it "updates the config data", -> - fsUtils.writeSync(config.configFilePath, "foo: { bar: 'quux', baz: 'bar'}") + fs.writeSync(config.configFilePath, "foo: { bar: 'quux', baz: 'bar'}") waitsFor 'update event', -> updatedHandler.callCount > 0 runs -> expect(config.get('foo.bar')).toBe 'quux' @@ -246,7 +245,7 @@ describe "Config", -> describe "when the config file changes to contain invalid cson", -> beforeEach -> spyOn(console, 'error') - fsUtils.writeSync(config.configFilePath, "}}}") + fs.writeSync(config.configFilePath, "}}}") waitsFor "error to be logged", -> console.error.callCount > 0 it "logs a warning and does not update config data", -> @@ -257,7 +256,7 @@ describe "Config", -> describe "when the config file subsequently changes again to contain valid cson", -> beforeEach -> - fsUtils.writeSync(config.configFilePath, "foo: bar: 'baz'") + fs.writeSync(config.configFilePath, "foo: bar: 'baz'") waitsFor 'update event', -> updatedHandler.callCount > 0 it "updates the config data and resumes saving", ->