This repository has been archived by the owner on Dec 15, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 292
/
develop-spec.coffee
75 lines (59 loc) · 2.85 KB
/
develop-spec.coffee
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
path = require 'path'
fs = require 'fs-extra'
temp = require 'temp'
apm = require '../lib/apm-cli'
describe "apm develop", ->
[repoPath, linkedRepoPath] = []
beforeEach ->
silenceOutput()
spyOnToken()
atomHome = temp.mkdirSync('apm-home-dir-')
process.env.ATOM_HOME = atomHome
atomReposHome = temp.mkdirSync('apm-repos-home-dir-')
process.env.ATOM_REPOS_HOME = atomReposHome
repoPath = path.join(atomReposHome, 'fake-package')
linkedRepoPath = path.join(atomHome, 'dev', 'packages', 'fake-package')
describe "when the package doesn't have a published repository url", ->
it "logs an error", ->
Develop = require '../lib/develop'
spyOn(Develop.prototype, "getRepositoryUrl").andCallFake (packageName, callback) ->
callback("Here is the error")
callback = jasmine.createSpy('callback')
apm.run(['develop', "fake-package"], callback)
waitsFor 'waiting for develop to complete', ->
callback.callCount is 1
runs ->
expect(callback.mostRecentCall.args[0]).toBe "Here is the error"
expect(fs.existsSync(repoPath)).toBeFalsy()
expect(fs.existsSync(linkedRepoPath)).toBeFalsy()
describe "when the repository hasn't been cloned", ->
it "clones the repository to ATOM_REPOS_HOME and links it to ATOM_HOME/dev/packages", ->
Develop = require '../lib/develop'
spyOn(Develop.prototype, "getRepositoryUrl").andCallFake (packageName, callback) ->
repoUrl = path.join(__dirname, 'fixtures', 'repo.git')
callback(null, repoUrl)
spyOn(Develop.prototype, "installDependencies").andCallFake (packageDirectory, options) ->
@linkPackage(packageDirectory, options)
callback = jasmine.createSpy('callback')
apm.run(['develop', "fake-package"], callback)
waitsFor 'waiting for develop to complete', ->
callback.callCount is 1
runs ->
expect(callback.mostRecentCall.args[0]).toBeFalsy()
expect(fs.existsSync(repoPath)).toBeTruthy()
expect(fs.existsSync(path.join(repoPath, 'Syntaxes', 'Makefile.plist'))).toBeTruthy()
expect(fs.existsSync(linkedRepoPath)).toBeTruthy()
expect(fs.realpathSync(linkedRepoPath)).toBe fs.realpathSync(repoPath)
describe "when the repository has already been cloned", ->
it "links it to ATOM_HOME/dev/packages", ->
fs.mkdirpSync(repoPath)
fs.writeFileSync(path.join(repoPath, "package.json"), "")
callback = jasmine.createSpy('callback')
apm.run(['develop', "fake-package"], callback)
waitsFor 'waiting for develop to complete', ->
callback.callCount is 1
runs ->
expect(callback.mostRecentCall.args[0]).toBeFalsy()
expect(fs.existsSync(repoPath)).toBeTruthy()
expect(fs.existsSync(linkedRepoPath)).toBeTruthy()
expect(fs.realpathSync(linkedRepoPath)).toBe fs.realpathSync(repoPath)