Jasmine 3: Use Spy#and to access SpyStrategy
diff --git a/test/android/test.exec.js b/test/android/test.exec.js
index 7d5dd13..69921b8 100644
--- a/test/android/test.exec.js
+++ b/test/android/test.exec.js
@@ -64,7 +64,7 @@
it('Test#001 : should process messages in order even when called recursively', function () {
var firstCallbackId = null;
var callCount = 0;
- nativeApi.exec.andCallFake(function (secret, service, action, callbackId, argsJson) {
+ nativeApi.exec.and.callFake(function (secret, service, action, callbackId, argsJson) {
expect(secret).toBe(1234);
++callCount;
if (callCount === 1) {
@@ -101,7 +101,7 @@
});
});
it('Test#002 : should process messages asynchronously', function () {
- nativeApi.exec.andCallFake(function (secret, service, action, callbackId, argsJson) {
+ nativeApi.exec.and.callFake(function (secret, service, action, callbackId, argsJson) {
expect(secret).toBe(1234);
return createCallbackMessage(true, false, 1, callbackId, 'stwo');
});
@@ -129,7 +129,7 @@
function performExecAndReturn (messages) {
- nativeApi.exec.andCallFake(function (secret, service, action, callbackId, argsJson) {
+ nativeApi.exec.and.callFake(function (secret, service, action, callbackId, argsJson) {
return messages;
});
@@ -214,7 +214,7 @@
it('Test#012 : should poll for more messages when hitting an *', function () {
var message1 = createCallbackMessage(false, false, 3, 'id', 'sfoo');
var message2 = createCallbackMessage(true, true, 1, 'id', 'f');
- nativeApi.retrieveJsMessages.andCallFake(function () {
+ nativeApi.retrieveJsMessages.and.callFake(function () {
expect(callbackSpy).toHaveBeenCalledWith('id', false, 3, ['foo'], false);
callbackSpy.reset();
return message2;
@@ -230,7 +230,7 @@
var message2 = createCallbackMessage(false, false, 3, 'id', 'scall2');
var message3 = createCallbackMessage(false, false, 3, 'id', 'scall3');
- callbackSpy.andCallFake(function () {
+ callbackSpy.and.callFake(function () {
if (callbackSpy.calls.length === 1) {
performExecAndReturn(message3);
}
diff --git a/test/test.channel.js b/test/test.channel.js
index 49de5ee..86cb405 100644
--- a/test/test.channel.js
+++ b/test/test.channel.js
@@ -229,7 +229,7 @@
});
it('Test#016 : should not prevent a callback from firing when it is removed during firing.', function () {
var testChannel = multi ? multiChannel : stickyChannel;
- var handler = jasmine.createSpy().andCallFake(function () { testChannel.unsubscribe(handler2); });
+ var handler = jasmine.createSpy().and.callFake(function () { testChannel.unsubscribe(handler2); });
var handler2 = jasmine.createSpy();
testChannel.subscribe(handler);
testChannel.subscribe(handler2);
@@ -253,8 +253,8 @@
expect(after.argsForCall[0]).toEqual({0: 1, 1: 2, 2: 3});
});
it('Test#018 : should instantly trigger the callback if the event is currently being fired.', function () {
- var handler1 = jasmine.createSpy().andCallFake(function () { stickyChannel.subscribe(handler2); });
- var handler2 = jasmine.createSpy().andCallFake(function (arg1) { expect(arg1).toEqual('foo'); });
+ var handler1 = jasmine.createSpy().and.callFake(function () { stickyChannel.subscribe(handler2); });
+ var handler2 = jasmine.createSpy().and.callFake(function (arg1) { expect(arg1).toEqual('foo'); });
stickyChannel.subscribe(handler1);
stickyChannel.fire('foo');
@@ -283,7 +283,7 @@
expectCallCount(after, 0);
});
it('Test#021 : should not trigger the callback if the event is currently being fired.', function () {
- var handler1 = jasmine.createSpy().andCallFake(function () { multiChannel.subscribe(handler2); });
+ var handler1 = jasmine.createSpy().and.callFake(function () { multiChannel.subscribe(handler2); });
var handler2 = jasmine.createSpy();
multiChannel.subscribe(handler1);
@@ -337,7 +337,7 @@
});
describe('onHasSubscribersChange', function () {
it('Test#027 : should be called only when the first subscriber is added and last subscriber is removed.', function () {
- var handler = jasmine.createSpy().andCallFake(function () {
+ var handler = jasmine.createSpy().and.callFake(function () {
if (callCount(handler) === 1) {
expect(this.numHandlers).toEqual(1);
} else {
diff --git a/test/test.pluginloader.js b/test/test.pluginloader.js
index abca2d1..5b9bc8c 100644
--- a/test/test.pluginloader.js
+++ b/test/test.pluginloader.js
@@ -51,7 +51,7 @@
}
it('Test#001 : should inject cordova_plugins.js when it is not already there', function () {
- injectScript.andCallFake(function (url, onload, onerror) {
+ injectScript.and.callFake(function (url, onload, onerror) {
// jsdom deficiencies:
if (typeof location !== 'undefined') {
expect(url).toBe(window.location.href.replace(/\/[^\/]*?$/, '/foo/cordova_plugins.js')); // eslint-disable-line no-useless-escape
@@ -90,7 +90,7 @@
{ 'file': 'some/path.js', 'id': 'some.id' }
];
});
- injectScript.andCallFake(function (url, onload, onerror) {
+ injectScript.and.callFake(function (url, onload, onerror) {
// jsdom deficiencies:
if (typeof location !== 'undefined') {
expect(url).toBe(window.location.href.replace(/\/[^\/]*?$/, '/foo/some/path.js')); // eslint-disable-line no-useless-escape