2013-09-20 00:51:53 +04:00
|
|
|
{fs} = require 'atom'
|
2013-10-21 18:23:22 +04:00
|
|
|
path = require 'path'
|
2013-10-21 17:20:19 +04:00
|
|
|
temp = require 'temp'
|
2013-09-18 05:58:41 +04:00
|
|
|
installer = require '../src/command-installer'
|
2013-05-15 21:28:31 +04:00
|
|
|
|
|
|
|
describe "install(commandPath, callback)", ->
|
2013-10-21 17:20:19 +04:00
|
|
|
directory = path.join(temp.dir, 'install-atom-command', 'atom')
|
|
|
|
commandPath = path.join(directory, 'source')
|
|
|
|
destinationPath = path.join(directory, 'bin', 'source')
|
2013-05-15 21:28:31 +04:00
|
|
|
|
|
|
|
beforeEach ->
|
|
|
|
spyOn(installer, 'findInstallDirectory').andCallFake (callback) ->
|
|
|
|
callback(directory)
|
|
|
|
|
2013-11-01 00:43:44 +04:00
|
|
|
fs.removeSync(directory) if fs.existsSync(directory)
|
2013-05-15 21:28:31 +04:00
|
|
|
|
|
|
|
it "symlinks the command and makes it executable", ->
|
2013-11-01 04:11:54 +04:00
|
|
|
fs.writeFileSync(commandPath, 'test')
|
2013-09-18 05:58:41 +04:00
|
|
|
expect(fs.isFileSync(commandPath)).toBeTruthy()
|
|
|
|
expect(fs.isExecutableSync(commandPath)).toBeFalsy()
|
|
|
|
expect(fs.isFileSync(destinationPath)).toBeFalsy()
|
2013-05-15 21:28:31 +04:00
|
|
|
|
|
|
|
installDone = false
|
|
|
|
installError = null
|
|
|
|
installer.install commandPath, (error) ->
|
|
|
|
installDone = true
|
|
|
|
installError = error
|
|
|
|
|
|
|
|
waitsFor -> installDone
|
|
|
|
|
|
|
|
runs ->
|
|
|
|
expect(installError).toBeNull()
|
2013-09-18 05:58:41 +04:00
|
|
|
expect(fs.isFileSync(destinationPath)).toBeTruthy()
|
2013-05-15 21:28:31 +04:00
|
|
|
expect(fs.realpathSync(destinationPath)).toBe fs.realpathSync(commandPath)
|
2013-09-18 05:58:41 +04:00
|
|
|
expect(fs.isExecutableSync(destinationPath)).toBeTruthy()
|