-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Broadcast asynchronous messages with callbacks to tree walker listeners
Squashed commit of the following: commit d84be27d69143579119e245a36dffb4180bf1b59 Author: Julien Biezemans <[email protected]> Date: Tue Jun 14 18:45:56 2011 +0200 Clean up commented code commit 35c6787b42b0952d246d7b639dfc6088cb80041e Author: Julien Biezemans <[email protected]> Date: Tue Jun 14 18:44:45 2011 +0200 Add TreeWalker.broadcastAfterEvent() and Event.replicateAsPostEvent() commit bdf5f070e7cffe0bcc40120d96e9069cb602b2c6 Author: Julien Biezemans <[email protected]> Date: Tue Jun 14 18:35:20 2011 +0200 Add Event.getName() and Event.getPayloadItem() commit 7bc8fd6aab5946370a7ce01c3627b81de79a0193 Author: Julien Biezemans <[email protected]> Date: Tue Jun 14 17:59:18 2011 +0200 Broadcast Event objects in TreeWalker.broadcastEvent() instead of a variable number of arbitrary parameters commit 5da22b354e48b7dbef1f7996e46a250d190ade87 Author: Julien Biezemans <[email protected]> Date: Tue Jun 14 17:21:25 2011 +0200 Add TreeWalker.broadcastBeforeEvent() and Event.replicateAsPreEvent() commit 3d98b6601d0ef978022536abf632eb5f08ac38a4 Author: Julien Biezemans <[email protected]> Date: Tue Jun 14 14:46:58 2011 +0200 Use Event objects instead of implicit parameters commit 8f77702 Author: Julien Biezemans <[email protected]> Date: Wed Jun 8 12:31:22 2011 +0200 Rename Message to Event commit a164205 Author: Julien Biezemans <[email protected]> Date: Wed Jun 8 12:00:44 2011 +0200 Clean unfinished spec commit 9dce11e Author: Julien Biezemans <[email protected]> Date: Tue Jun 7 18:45:23 2011 +0200 Refactor message, event and payload wording to consistent use commit ae2b3f4 Author: Julien Biezemans <[email protected]> Date: Tue Jun 7 17:34:36 2011 +0200 Add wrapUserFunctionAndAfterMessageBroadcast() and wrapAfterMessageBroadcast() commit 55fe390 Author: Julien Biezemans <[email protected]> Date: Tue Jun 7 15:29:11 2011 +0200 Add extractCallbackFromArguments() commit 95f5a07 Author: Julien Biezemans <[email protected]> Date: Tue Jun 7 15:21:40 2011 +0200 Add extractNonMessagePayloadArgumentsFromArguments() commit d49ce12 Author: Julien Biezemans <[email protected]> Date: Tue Jun 7 15:05:44 2011 +0200 Add extractUserFunctionFromArguments() commit a6d3287 Author: Julien Biezemans <[email protected]> Date: Tue Jun 7 14:36:08 2011 +0200 Add Cucumber.Util.Arguments commit fc367ea Author: Julien Biezemans <[email protected]> Date: Tue Jun 7 14:13:49 2011 +0200 Add extractMessagePayloadFromArguments() commit 3e69e98 Author: Julien Biezemans <[email protected]> Date: Tue Jun 7 11:42:37 2011 +0200 Spec broadcastUserFunction() commit b669e01 Author: Julien Biezemans <[email protected]> Date: Mon Jun 6 16:59:59 2011 +0200 Refactor visitXXX() methods
- Loading branch information
Showing
5 changed files
with
488 additions
and
210 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
require('../../../support/spec_helper'); | ||
|
||
describe("Cucumber.Ast.TreeWalker.Event", function() { | ||
var Cucumber = require('cucumber'); | ||
var event, name, payload; | ||
|
||
beforeEach(function() { | ||
name = "SomeEvent"; | ||
payloadItems = [ | ||
createSpy("First payload item"), | ||
createSpy("Second payload item"), | ||
createSpy("Third payload item") | ||
]; | ||
payload = { | ||
firstItem: payloadItems[0], | ||
secondItem: payloadItems[1], | ||
thirdItem: payloadItems[2] | ||
}; | ||
event = Cucumber.Ast.TreeWalker.Event(name, payload); | ||
}); | ||
|
||
describe("getName()", function() { | ||
it("returns the name of the event", function() { | ||
expect(event.getName()).toBe(name); | ||
}); | ||
}); | ||
|
||
describe("replicateAsPreEvent()", function() { | ||
var preEvent; | ||
|
||
beforeEach(function() { | ||
preEvent = createSpy("Pre-event (before)"); | ||
spyOn(Cucumber.Ast.TreeWalker, 'Event').andReturn(preEvent); | ||
}); | ||
|
||
it("creates a new event with the before prefix prepended to the event name and the same payload", function() { | ||
var newName = Cucumber.Ast.TreeWalker.BEFORE_EVENT_NAME_PREFIX + name; | ||
event.replicateAsPreEvent(); | ||
expect(Cucumber.Ast.TreeWalker.Event).toHaveBeenCalledWith(newName, payload); | ||
}); | ||
|
||
it("returns the new event", function() { | ||
expect(event.replicateAsPreEvent()).toBe(preEvent); | ||
}); | ||
}); | ||
|
||
describe("replicateAsPostEvent()", function() { | ||
var postEvent; | ||
|
||
beforeEach(function() { | ||
postEvent = createSpy("Post-event (after)"); | ||
spyOn(Cucumber.Ast.TreeWalker, 'Event').andReturn(postEvent); | ||
}); | ||
|
||
it("creates a new event with the after prefix prepended to the event name and the same payload", function() { | ||
var newName = Cucumber.Ast.TreeWalker.AFTER_EVENT_NAME_PREFIX + name; | ||
event.replicateAsPostEvent(); | ||
expect(Cucumber.Ast.TreeWalker.Event).toHaveBeenCalledWith(newName, payload); | ||
}); | ||
|
||
it("returns the new event", function() { | ||
expect(event.replicateAsPostEvent()).toBe(postEvent); | ||
}); | ||
}); | ||
|
||
describe("getPayloadItem()", function() { | ||
it("returns the requested item from the payload", function() { | ||
expect(event.getPayloadItem('firstItem')).toBe(payloadItems[0]); | ||
expect(event.getPayloadItem('secondItem')).toBe(payloadItems[1]); | ||
expect(event.getPayloadItem('thirdItem')).toBe(payloadItems[2]); | ||
}); | ||
|
||
it("returns undefined when the item does not exist in the payload", function() { | ||
expect(event.getPayloadItem('unknownItem')).toBeUndefined(); | ||
}); | ||
}); | ||
}); |
Oops, something went wrong.