From c2b558a2daef3f947066ec0955d039c8e893411d Mon Sep 17 00:00:00 2001 From: Steve Gravrock Date: Thu, 17 Sep 2020 14:47:25 -0700 Subject: [PATCH] Fail specs that try to combine two forms of async --- lib/jasmine-core/jasmine.js | 8 +++----- spec/core/QueueRunnerSpec.js | 21 ++++++++++----------- src/core/QueueRunner.js | 8 +++----- 3 files changed, 16 insertions(+), 21 deletions(-) diff --git a/lib/jasmine-core/jasmine.js b/lib/jasmine-core/jasmine.js index 3b644f9a..cfbd607d 100644 --- a/lib/jasmine-core/jasmine.js +++ b/lib/jasmine-core/jasmine.js @@ -7449,18 +7449,16 @@ getJasmineRequireObj().QueueRunner = function(j$) { if (retval && j$.isFunction_(retval.then)) { // Issue a warning that matches the user's code if (j$.isAsyncFunction_(fn)) { - this.deprecated( + this.onException( 'An asynchronous before/it/after ' + 'function was defined with the async keyword but also took a ' + - 'done callback. This is not supported and will stop working in' + - ' the future. Either remove the done callback (recommended) or ' + + 'done callback. Either remove the done callback (recommended) or ' + 'remove the async keyword.' ); } else { - this.deprecated( + this.onException( 'An asynchronous before/it/after ' + 'function took a done callback but also returned a promise. ' + - 'This is not supported and will stop working in the future. ' + 'Either remove the done callback (recommended) or change the ' + 'function to not return a promise.' ); diff --git a/spec/core/QueueRunnerSpec.js b/spec/core/QueueRunnerSpec.js index 7333b02a..1aaba300 100644 --- a/spec/core/QueueRunnerSpec.js +++ b/spec/core/QueueRunnerSpec.js @@ -513,46 +513,45 @@ describe('QueueRunner', function() { expect(queueableFn2.fn).toHaveBeenCalled(); }); - it('issues a deprecation if the function also takes a parameter', function() { + it('issues an error if the function also takes a parameter', function() { var queueableFn = { fn: function(done) { return new StubPromise(); } }, - deprecated = jasmine.createSpy('deprecated'), + onException = jasmine.createSpy('onException'), queueRunner = new jasmineUnderTest.QueueRunner({ queueableFns: [queueableFn], - deprecated: deprecated + onException: onException }), env = jasmineUnderTest.getEnv(); queueRunner.execute(); - expect(deprecated).toHaveBeenCalledWith( + expect(onException).toHaveBeenCalledWith( 'An asynchronous ' + 'before/it/after function took a done callback but also returned a ' + - 'promise. This is not supported and will stop working in the future. ' + + 'promise. ' + 'Either remove the done callback (recommended) or change the function ' + 'to not return a promise.' ); }); - it('issues a more specific deprecation if the function is `async`', function() { + it('issues a more specific error if the function is `async`', function() { jasmine.getEnv().requireAsyncAwait(); eval('var fn = async function(done){};'); - var deprecated = jasmine.createSpy('deprecated'), + var onException = jasmine.createSpy('onException'), queueRunner = new jasmineUnderTest.QueueRunner({ queueableFns: [{ fn: fn }], - deprecated: deprecated + onException: onException }); queueRunner.execute(); - expect(deprecated).toHaveBeenCalledWith( + expect(onException).toHaveBeenCalledWith( 'An asynchronous ' + 'before/it/after function was defined with the async keyword but ' + - 'also took a done callback. This is not supported and will stop ' + - 'working in the future. Either remove the done callback ' + + 'also took a done callback. Either remove the done callback ' + '(recommended) or remove the async keyword.' ); }); diff --git a/src/core/QueueRunner.js b/src/core/QueueRunner.js index be9e7f62..b3458bab 100644 --- a/src/core/QueueRunner.js +++ b/src/core/QueueRunner.js @@ -218,18 +218,16 @@ getJasmineRequireObj().QueueRunner = function(j$) { if (retval && j$.isFunction_(retval.then)) { // Issue a warning that matches the user's code if (j$.isAsyncFunction_(fn)) { - this.deprecated( + this.onException( 'An asynchronous before/it/after ' + 'function was defined with the async keyword but also took a ' + - 'done callback. This is not supported and will stop working in' + - ' the future. Either remove the done callback (recommended) or ' + + 'done callback. Either remove the done callback (recommended) or ' + 'remove the async keyword.' ); } else { - this.deprecated( + this.onException( 'An asynchronous before/it/after ' + 'function took a done callback but also returned a promise. ' + - 'This is not supported and will stop working in the future. ' + 'Either remove the done callback (recommended) or change the ' + 'function to not return a promise.' );