mirror of
https://github.com/atom/atom.git
synced 2026-04-06 03:02:13 -04:00
Move deferred activation specs to atom-spec
This commit is contained in:
@@ -18,32 +18,3 @@ describe "AtomPackage", ->
|
||||
expect(object.data).toBe 'Hello'
|
||||
expect(pack.mainModule).toBeDefined()
|
||||
expect(pack.mainModule.activateCallCount).toBe 0
|
||||
|
||||
describe ".activate()", ->
|
||||
beforeEach ->
|
||||
window.rootView = new RootView
|
||||
packageMainModule = require 'fixtures/packages/package-with-activation-events/main'
|
||||
spyOn(packageMainModule, 'activate').andCallThrough()
|
||||
|
||||
describe "when the package metadata includes activation events", ->
|
||||
beforeEach ->
|
||||
pack.activate()
|
||||
|
||||
it "defers activating the package until an activation event bubbles to the root view", ->
|
||||
expect(packageMainModule.activate).not.toHaveBeenCalled()
|
||||
rootView.trigger 'activation-event'
|
||||
expect(packageMainModule.activate).toHaveBeenCalled()
|
||||
|
||||
it "triggers the activation event on all handlers registered during activation", ->
|
||||
rootView.open('sample.js')
|
||||
editor = rootView.getActiveView()
|
||||
eventHandler = jasmine.createSpy("activation-event")
|
||||
editor.command 'activation-event', eventHandler
|
||||
editor.trigger 'activation-event'
|
||||
expect(packageMainModule.activate.callCount).toBe 1
|
||||
expect(packageMainModule.activationEventCallCount).toBe 1
|
||||
expect(eventHandler.callCount).toBe 1
|
||||
editor.trigger 'activation-event'
|
||||
expect(packageMainModule.activationEventCallCount).toBe 2
|
||||
expect(eventHandler.callCount).toBe 2
|
||||
expect(packageMainModule.activate.callCount).toBe 1
|
||||
|
||||
@@ -33,6 +33,34 @@ describe "the `atom` global", ->
|
||||
expect(config.get('package-with-config-defaults.numbers.one')).toBe 1
|
||||
expect(config.get('package-with-config-defaults.numbers.two')).toBe 2
|
||||
|
||||
describe "when the package metadata includes activation events", ->
|
||||
[mainModule, pack] = []
|
||||
|
||||
beforeEach ->
|
||||
mainModule = require 'package-with-activation-events/index'
|
||||
spyOn(mainModule, 'activate').andCallThrough()
|
||||
pack = atom.activatePackage('package-with-activation-events')
|
||||
|
||||
it "defers requiring/activating the main module until an activation event bubbles to the root view", ->
|
||||
expect(pack.mainModule).toBeNull()
|
||||
expect(mainModule.activate).not.toHaveBeenCalled()
|
||||
rootView.trigger 'activation-event'
|
||||
expect(mainModule.activate).toHaveBeenCalled()
|
||||
|
||||
it "triggers the activation event on all handlers registered during activation", ->
|
||||
rootView.open()
|
||||
editor = rootView.getActiveView()
|
||||
eventHandler = jasmine.createSpy("activation-event")
|
||||
editor.command 'activation-event', eventHandler
|
||||
editor.trigger 'activation-event'
|
||||
expect(mainModule.activate.callCount).toBe 1
|
||||
expect(mainModule.activationEventCallCount).toBe 1
|
||||
expect(eventHandler.callCount).toBe 1
|
||||
editor.trigger 'activation-event'
|
||||
expect(mainModule.activationEventCallCount).toBe 2
|
||||
expect(eventHandler.callCount).toBe 2
|
||||
expect(mainModule.activate.callCount).toBe 1
|
||||
|
||||
describe "when the package has no main module", ->
|
||||
it "does not throw an exception", ->
|
||||
spyOn(console, "error")
|
||||
|
||||
Reference in New Issue
Block a user