Publish Vulpes Preview 15 sources for desktop, Android and Tundra
Share Gaia assets and adapters, keep private profiles and development documents local, and update both public READMEs.
This commit is contained in:
parent
93e3a48004
commit
b38dea0597
25901 changed files with 9982925 additions and 369 deletions
87
gaia/apps/calendar/test/unit/common/responder_test.js
Executable file
87
gaia/apps/calendar/test/unit/common/responder_test.js
Executable file
|
|
@ -0,0 +1,87 @@
|
|||
/**
|
||||
* Responder is actually an downstream of test-agent
|
||||
* porting the handleEvent thing over here for now
|
||||
* to eventually be moved back with the other tweaks.
|
||||
*/
|
||||
define(function(require) {
|
||||
'use strict';
|
||||
|
||||
var Responder = require('common/responder');
|
||||
|
||||
suite('responder', function() {
|
||||
var subject;
|
||||
|
||||
setup(function() {
|
||||
subject = new Responder();
|
||||
});
|
||||
|
||||
test('multi arg responder', function() {
|
||||
var calledWith;
|
||||
|
||||
subject.on('test', function() {
|
||||
calledWith = Array.slice(arguments);
|
||||
});
|
||||
|
||||
subject.respond(['test', 'one', 'two', 'three']);
|
||||
assert.deepEqual(calledWith, ['one', 'two', 'three']);
|
||||
});
|
||||
|
||||
suite('handleEvent', function() {
|
||||
test('object', function() {
|
||||
var events = {};
|
||||
var target = {
|
||||
// mimic the actual eventTarget api's
|
||||
handleEvent: function(e) {
|
||||
var type = e.type;
|
||||
|
||||
if (!(type in events)) {
|
||||
events[type] = [];
|
||||
}
|
||||
|
||||
events[type].push(e.data);
|
||||
}
|
||||
};
|
||||
|
||||
subject.on('foo', target);
|
||||
subject.on('foo', target);
|
||||
subject.on('bar', target);
|
||||
|
||||
subject.emit('foo', 1);
|
||||
subject.emit('bar', 1, 2);
|
||||
|
||||
assert.deepEqual(
|
||||
events.foo,
|
||||
[[1], [1]]
|
||||
);
|
||||
|
||||
assert.deepEqual(
|
||||
events.bar,
|
||||
[[1, 2]]
|
||||
);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
test('#emitWhenListener', function(done) {
|
||||
subject.emitWhenListener('foo', 'bar');
|
||||
subject.emitWhenListener('foo', 'baz');
|
||||
|
||||
// Let the event loop tick before listening for the 'foo' topic.
|
||||
setTimeout(() => {
|
||||
var count = 0;
|
||||
subject.on('foo', function onFoo(word) {
|
||||
if (count === 0) {
|
||||
assert.equal(word, 'bar');
|
||||
count++;
|
||||
return;
|
||||
}
|
||||
|
||||
assert.equal(word, 'baz');
|
||||
subject.off('foo', onFoo);
|
||||
done();
|
||||
});
|
||||
}, 0);
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
Loading…
Reference in a new issue