2012-12-19 06:47:20 +04:00
|
|
|
RootView = require 'root-view'
|
2013-01-04 02:10:11 +04:00
|
|
|
{$$} = require 'space-pen'
|
2012-12-19 06:47:20 +04:00
|
|
|
|
2013-02-08 00:17:34 +04:00
|
|
|
fdescribe "the `atom` global", ->
|
|
|
|
beforeEach ->
|
|
|
|
new RootView
|
|
|
|
|
2012-12-19 06:47:20 +04:00
|
|
|
describe ".loadPackage(name)", ->
|
2013-01-03 04:40:03 +04:00
|
|
|
[extension, stylesheetPath] = []
|
2012-12-19 06:47:20 +04:00
|
|
|
|
|
|
|
beforeEach ->
|
2012-12-20 06:24:44 +04:00
|
|
|
extension = require "package-with-module"
|
2013-01-03 04:40:03 +04:00
|
|
|
stylesheetPath = require.resolve("fixtures/packages/package-with-module/stylesheets/styles.css")
|
|
|
|
|
|
|
|
afterEach ->
|
|
|
|
removeStylesheet(stylesheetPath)
|
2012-12-19 06:47:20 +04:00
|
|
|
|
|
|
|
it "requires and activates the package's main module if it exists", ->
|
2012-12-20 06:24:44 +04:00
|
|
|
spyOn(rootView, 'activatePackage').andCallThrough()
|
|
|
|
atom.loadPackage("package-with-module")
|
2013-01-22 20:56:18 +04:00
|
|
|
expect(rootView.activatePackage).toHaveBeenCalled()
|
2013-01-03 04:40:03 +04:00
|
|
|
|
2013-01-09 21:20:19 +04:00
|
|
|
it "logs warning instead of throwing an exception if a package fails to load", ->
|
2013-01-27 23:12:39 +04:00
|
|
|
config.set("core.disabledPackages", [])
|
2013-01-09 21:20:19 +04:00
|
|
|
spyOn(console, "warn")
|
|
|
|
expect(-> atom.loadPackage("package-that-throws-an-exception")).not.toThrow()
|
|
|
|
expect(console.warn).toHaveBeenCalled()
|
|
|
|
|
2013-01-04 02:10:11 +04:00
|
|
|
describe "keymap loading", ->
|
|
|
|
describe "when package.json does not contain a 'keymaps' manifest", ->
|
2013-02-01 00:01:02 +04:00
|
|
|
it "loads all the .cson/.json files in the keymaps directory", ->
|
2013-01-04 02:10:11 +04:00
|
|
|
element1 = $$ -> @div class: 'test-1'
|
|
|
|
element2 = $$ -> @div class: 'test-2'
|
2013-02-01 00:01:02 +04:00
|
|
|
element3 = $$ -> @div class: 'test-3'
|
2013-01-04 02:10:11 +04:00
|
|
|
|
|
|
|
expect(keymap.bindingsForElement(element1)['ctrl-z']).toBeUndefined()
|
|
|
|
expect(keymap.bindingsForElement(element2)['ctrl-z']).toBeUndefined()
|
2013-02-01 00:01:02 +04:00
|
|
|
expect(keymap.bindingsForElement(element3)['ctrl-z']).toBeUndefined()
|
2013-01-04 02:10:11 +04:00
|
|
|
|
|
|
|
atom.loadPackage("package-with-module")
|
|
|
|
|
|
|
|
expect(keymap.bindingsForElement(element1)['ctrl-z']).toBe "test-1"
|
|
|
|
expect(keymap.bindingsForElement(element2)['ctrl-z']).toBe "test-2"
|
2013-02-01 00:01:02 +04:00
|
|
|
expect(keymap.bindingsForElement(element3)['ctrl-z']).toBeUndefined()
|
2013-01-04 02:10:11 +04:00
|
|
|
|
|
|
|
describe "when package.json contains a 'keymaps' manifest", ->
|
|
|
|
it "loads only the keymaps specified by the manifest, in the specified order", ->
|
|
|
|
element1 = $$ -> @div class: 'test-1'
|
|
|
|
element3 = $$ -> @div class: 'test-3'
|
|
|
|
|
|
|
|
expect(keymap.bindingsForElement(element1)['ctrl-z']).toBeUndefined()
|
|
|
|
|
|
|
|
atom.loadPackage("package-with-keymaps-manifest")
|
|
|
|
|
|
|
|
expect(keymap.bindingsForElement(element1)['ctrl-z']).toBe 'keymap-1'
|
|
|
|
expect(keymap.bindingsForElement(element1)['ctrl-n']).toBe 'keymap-2'
|
|
|
|
expect(keymap.bindingsForElement(element3)['ctrl-y']).toBeUndefined()
|
|
|
|
|
2013-01-03 04:40:03 +04:00
|
|
|
it "loads stylesheets associated with the package", ->
|
|
|
|
stylesheetPath = require.resolve("fixtures/packages/package-with-module/stylesheets/styles.css")
|
|
|
|
expect(stylesheetElementForId(stylesheetPath).length).toBe 0
|
|
|
|
atom.loadPackage("package-with-module")
|
|
|
|
expect(stylesheetElementForId(stylesheetPath).length).toBe 1
|
2013-01-28 10:38:11 +04:00
|
|
|
|
|
|
|
describe ".loadPackages()", ->
|
|
|
|
beforeEach ->
|
2013-01-29 02:23:16 +04:00
|
|
|
spyOn(syntax, 'addGrammar')
|
|
|
|
|
2013-01-28 10:38:11 +04:00
|
|
|
it "terminates the worker when all packages have been loaded", ->
|
|
|
|
spyOn(Worker.prototype, 'terminate').andCallThrough()
|
|
|
|
eventHandler = jasmine.createSpy('eventHandler')
|
2013-01-29 02:34:45 +04:00
|
|
|
syntax.on 'grammars-loaded', eventHandler
|
2013-01-28 10:38:11 +04:00
|
|
|
disabledPackages = config.get("core.disabledPackages")
|
|
|
|
disabledPackages.push('textmate-package.tmbundle')
|
|
|
|
config.set "core.disabledPackages", disabledPackages
|
|
|
|
atom.loadPackages()
|
|
|
|
|
|
|
|
waitsFor "all packages to load", 5000, -> eventHandler.callCount > 0
|
|
|
|
|
|
|
|
runs ->
|
|
|
|
expect(Worker.prototype.terminate).toHaveBeenCalled()
|
|
|
|
expect(Worker.prototype.terminate.calls.length).toBe 1
|