modified @listens test fixture so I can use it for addEventListeners too

This commit is contained in:
mathematicalcoffee 2013-03-18 14:31:46 +10:00
parent a789bc3187
commit 17a69c727f
2 changed files with 41 additions and 10 deletions

View File

@ -1,7 +1,34 @@
/** An event handler.
* @function
* @listens Foo
* @listens Bar
/** @module myModule */
/** An event (has listeners).
* @event MyEvent
* @memberof module:myModule
* @param {number} foo - asdf. */
/** A handler.
* @listens module:myModule.MyEvent
* @listens module:myModule~Events.event:Event2
* @listens fakeEvent
*/
function handler () {
function MyHandler() {
}
/** Another handler.
* @listens module:myModule.MyEvent
*/
function AnotherHandler() {
}
/** a namespace.
* @namespace */
var Events = {
};
/** Another event (has listeners).
* @event Event2
* @memberof module:myModule~Events
*/
/** An event with no listeners.
* @event module:myModule#Event3 */

View File

@ -1,11 +1,15 @@
describe("@listens tag", function() {
var docSet = jasmine.getDocSetFromFile('test/fixtures/listenstag.js'),
doc = docSet.getByLongname('handler')[0];
doc = docSet.getByLongname('module:myModule~MyHandler')[0];
it("should create a 'listens' property on the doclet, an array, with the events that are listened to", function() {
it("should create a 'listens' property on the doclet, an array, with the events that are listened to (with event namespace)", function() {
expect(Array.isArray(doc.listens)).toBeTruthy();
expect(doc.listens.length).toBe(2);
expect(doc.listens).toContain('event:Foo');
expect(doc.listens).toContain('event:Bar');
expect(doc.listens).toContain('module:myModule.event:MyEvent');
expect(doc.listens).toContain('module:myModule~Events.event:Event2');
});
it("includes events even if non-existent", function() {
expect(doc.listens.length).toBe(3);
expect(doc.listens).toContain('event:fakeEvent');
});
});