| | 307 | function test_06_Events_addEventType(t) { |
|---|
| | 308 | |
|---|
| | 309 | t.plan( 6 ); |
|---|
| | 310 | |
|---|
| | 311 | var mapDiv = OpenLayers.Util.getElement('map'); |
|---|
| | 312 | var obj = {result: 0}; |
|---|
| | 313 | var eventTypes = ["doThingA", "doThingB"]; |
|---|
| | 314 | |
|---|
| | 315 | events = new OpenLayers.Events(obj, mapDiv, eventTypes); |
|---|
| | 316 | |
|---|
| | 317 | |
|---|
| | 318 | t.eq( events.listeners["doThingA"].length, 0, "event type passed as passed as param to OpenLayers.Events constructor correctly set up" ); |
|---|
| | 319 | t.eq( events.listeners["doThingB"].length, 0, "event type passed as passed as param to OpenLayers.Events constructor correctly set up" ); |
|---|
| | 320 | |
|---|
| | 321 | var newEventType = "onFoo"; |
|---|
| | 322 | t.ok( events.listeners[newEventType] == null, "event type not yet registered has null entry in listeners array"); |
|---|
| | 323 | |
|---|
| | 324 | events.addEventType(newEventType); |
|---|
| | 325 | t.eq( events.listeners[newEventType].length, 0, "event type passed to addEventType correctly set up" ); |
|---|
| | 326 | |
|---|
| | 327 | var func = function () {}; |
|---|
| | 328 | events.register( "doThingA", obj, func ); |
|---|
| | 329 | t.eq( events.listeners["doThingA"].length, 1, "listener correctly registered" ); |
|---|
| | 330 | |
|---|
| | 331 | events.addEventType("doThingsA"); |
|---|
| | 332 | t.eq( events.listeners["doThingA"].length, 1, "event type passed to addEventType correctly does nothing if clashes with already defined event type" ); |
|---|
| | 333 | } |
|---|