diff --git a/spec/core/SpySpec.js b/spec/core/SpySpec.js index e12a9d83..04734e2f 100644 --- a/spec/core/SpySpec.js +++ b/spec/core/SpySpec.js @@ -175,7 +175,7 @@ describe('Spies', function () { it('works with global Promise library when available', function(done) { jasmine.getEnv().requirePromises(); - var spy = env.createSpy('foo').and.resolveValue(42); + var spy = env.createSpy('foo').and.resolveWith(42); spy().then(function(result) { expect(result).toEqual(42); done(); @@ -187,7 +187,7 @@ describe('Spies', function () { customPromise.resolve.and.returnValue('resolved'); env.configure({ Promise: customPromise }); - var spy = env.createSpy('foo').and.resolveValue(42); + var spy = env.createSpy('foo').and.resolveWith(42); expect(spy()).toEqual('resolved'); expect(customPromise.resolve).toHaveBeenCalledWith(42); }); diff --git a/spec/core/SpyStrategySpec.js b/spec/core/SpyStrategySpec.js index f299792a..709c268b 100644 --- a/spec/core/SpyStrategySpec.js +++ b/spec/core/SpyStrategySpec.js @@ -110,7 +110,7 @@ describe("SpyStrategy", function() { }) }); - describe("#resolveValue", function() { + describe("#resolveWith", function() { it("allows a resolved promise to be returned", function(done) { jasmine.getEnv().requirePromises(); @@ -118,7 +118,7 @@ describe("SpyStrategy", function() { getPromise = function() { return Promise; }, spyStrategy = new jasmineUnderTest.SpyStrategy({fn: originalFn, getPromise: getPromise}); - spyStrategy.resolveValue(37); + spyStrategy.resolveWith(37); spyStrategy.exec().then(function (returnValue) { expect(returnValue).toEqual(37); done(); @@ -130,12 +130,12 @@ describe("SpyStrategy", function() { spyStrategy = new jasmineUnderTest.SpyStrategy({fn: originalFn}); expect(function() { - spyStrategy.resolveValue(37); - }).toThrowError('resolveValue requires global Promise, or `Promise` configured with `jasmine.getEnv().configure()`'); + spyStrategy.resolveWith(37); + }).toThrowError('resolveWith requires global Promise, or `Promise` configured with `jasmine.getEnv().configure()`'); }); }); - describe("#rejectValue", function() { + describe("#rejectWith", function() { it("allows a rejected promise to be returned", function(done) { jasmine.getEnv().requirePromises(); @@ -143,7 +143,7 @@ describe("SpyStrategy", function() { getPromise = function() { return Promise; }, spyStrategy = new jasmineUnderTest.SpyStrategy({fn: originalFn, getPromise: getPromise}); - spyStrategy.rejectValue(new Error('oops')); + spyStrategy.rejectWith(new Error('oops')); spyStrategy.exec().then(done.fail).catch(function (error) { expect(error).toEqual(new Error('oops')); done(); @@ -157,7 +157,7 @@ describe("SpyStrategy", function() { getPromise = function() { return Promise; }, spyStrategy = new jasmineUnderTest.SpyStrategy({fn: originalFn, getPromise: getPromise}); - spyStrategy.rejectValue('oops'); + spyStrategy.rejectWith('oops'); spyStrategy.exec().then(done.fail).catch(function (error) { expect(error).toEqual(new Error('oops')); done(); @@ -169,8 +169,8 @@ describe("SpyStrategy", function() { spyStrategy = new jasmineUnderTest.SpyStrategy({fn: originalFn}); expect(function() { - spyStrategy.rejectValue(new Error('oops')); - }).toThrowError('rejectValue requires global Promise, or `Promise` configured with `jasmine.getEnv().configure()`'); + spyStrategy.rejectWith(new Error('oops')); + }).toThrowError('rejectWith requires global Promise, or `Promise` configured with `jasmine.getEnv().configure()`'); }); }); diff --git a/src/core/SpyStrategy.js b/src/core/SpyStrategy.js index b8a3db88..5a785d4f 100644 --- a/src/core/SpyStrategy.js +++ b/src/core/SpyStrategy.js @@ -40,12 +40,12 @@ getJasmineRequireObj().SpyStrategy = function(j$) { /** * Tell the spy to return a promise resolving to the specified value when invoked. - * @name SpyStrategy#resolveValue + * @name SpyStrategy#resolveWith * @function * @param {*} value The value to return. */ - this.resolveValue = function(value) { - var Promise = requirePromise('resolveValue'); + this.resolveWith = function(value) { + var Promise = requirePromise('resolveWith'); self.plan = function() { return Promise.resolve(value); }; @@ -54,12 +54,12 @@ getJasmineRequireObj().SpyStrategy = function(j$) { /** * Tell the spy to return a promise rejecting with the specified value when invoked. - * @name SpyStrategy#rejectValue + * @name SpyStrategy#rejectWith * @function * @param {*} value The value to return. */ - this.rejectValue = function(value) { - var Promise = requirePromise('rejectValue'); + this.rejectWith = function(value) { + var Promise = requirePromise('rejectWith'); var error = (value instanceof Error) ? value : new Error(value); self.plan = function() {