You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by pu...@apache.org on 2015/03/19 02:30:36 UTC
js commit: CB-8711 wait for all callbacks before evaluating
expectations
Repository: cordova-js
Updated Branches:
refs/heads/master 579d070bd -> 74ae2f870
CB-8711 wait for all callbacks before evaluating expectations
Project: http://git-wip-us.apache.org/repos/asf/cordova-js/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-js/commit/74ae2f87
Tree: http://git-wip-us.apache.org/repos/asf/cordova-js/tree/74ae2f87
Diff: http://git-wip-us.apache.org/repos/asf/cordova-js/diff/74ae2f87
Branch: refs/heads/master
Commit: 74ae2f8702e14122aa55ddf98837386330ebf905
Parents: 579d070
Author: Jesse MacFadyen <pu...@gmail.com>
Authored: Wed Mar 18 18:19:45 2015 -0700
Committer: Jesse MacFadyen <pu...@gmail.com>
Committed: Wed Mar 18 18:30:15 2015 -0700
----------------------------------------------------------------------
test/android/test.exec.js | 18 +++++++++++++++---
1 file changed, 15 insertions(+), 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-js/blob/74ae2f87/test/android/test.exec.js
----------------------------------------------------------------------
diff --git a/test/android/test.exec.js b/test/android/test.exec.js
index 6541f3c..a8e0b24 100644
--- a/test/android/test.exec.js
+++ b/test/android/test.exec.js
@@ -19,7 +19,7 @@
*
*/
-describe('exec.processMessages', function () {
+describe('android exec.processMessages', function () {
var cordova = require('cordova'),
exec = require('cordova/android/exec'),
nativeApiProvider = require('cordova/android/nativeapiprovider'),
@@ -127,13 +127,14 @@ describe('exec.processMessages', function () {
});
function performExecAndReturn(messages) {
+
nativeApi.exec.andCallFake(function(secret, service, action, callbackId, argsJson) {
return messages;
});
- var winSpy = jasmine.createSpy('win');
-
exec(null, null, 'Service', 'action', []);
+ // note: sometimes we need to wait for multiple callbacks, this returns after one
+ // see 'should handle multiple messages' below
waitsFor(function() { return callbackSpy.wasCalled }, 200);
}
@@ -198,6 +199,12 @@ describe('exec.processMessages', function () {
var message2 = createCallbackMessage(true, true, 1, 'id', 'f');
var messages = message1 + message2;
performExecAndReturn(messages);
+
+ // need to wait for ALL the callbacks before we check our expects
+ waitsFor(function(){
+ return callbackSpy.calls.length > 1;
+ },200);
+
runs(function() {
expect(callbackSpy).toHaveBeenCalledWith('id', false, 3, ['foo'], false);
expect(callbackSpy).toHaveBeenCalledWith('id', true, 1, [false], true);
@@ -228,6 +235,11 @@ describe('exec.processMessages', function () {
}
});
performExecAndReturn(message1 + message2);
+ // need to wait for ALL the callbacks before we check our expects
+ waitsFor(function(){
+ return callbackSpy.calls.length > 2;
+ },200);
+
runs(function() {
expect(callbackSpy.argsForCall.length).toEqual(3);
expect(callbackSpy.argsForCall[0]).toEqual(['id', false, 3, ['call1'], false]);
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org