Deprecated the Promise config setting
4.0 will only support environments that have native promises, so there will no longer be a need for a user-supplied promise library
This commit is contained in:
@@ -1175,6 +1175,8 @@ getJasmineRequireObj().Env = function(j$) {
|
|||||||
* @since 3.5.0
|
* @since 3.5.0
|
||||||
* @type function
|
* @type function
|
||||||
* @default undefined
|
* @default undefined
|
||||||
|
* @deprecated In a future version, Jasmine will ignore the Promise config
|
||||||
|
* property and always create native promises instead.
|
||||||
*/
|
*/
|
||||||
Promise: undefined,
|
Promise: undefined,
|
||||||
/**
|
/**
|
||||||
@@ -1331,6 +1333,11 @@ getJasmineRequireObj().Env = function(j$) {
|
|||||||
typeof configuration.Promise.reject === 'function'
|
typeof configuration.Promise.reject === 'function'
|
||||||
) {
|
) {
|
||||||
customPromise = configuration.Promise;
|
customPromise = configuration.Promise;
|
||||||
|
self.deprecated(
|
||||||
|
'The `Promise` config property is deprecated. Future versions ' +
|
||||||
|
'of Jasmine will create native promises even if the `Promise` ' +
|
||||||
|
'config property is set. Please remove it.'
|
||||||
|
);
|
||||||
} else {
|
} else {
|
||||||
throw new Error(
|
throw new Error(
|
||||||
'Custom promise library missing `resolve`/`reject` functions'
|
'Custom promise library missing `resolve`/`reject` functions'
|
||||||
|
|||||||
@@ -399,11 +399,17 @@ describe('Env', function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('can be configured with a custom library', function() {
|
it('can be configured with a custom library', function() {
|
||||||
|
spyOn(env, 'deprecated');
|
||||||
var myLibrary = {
|
var myLibrary = {
|
||||||
resolve: jasmine.createSpy(),
|
resolve: jasmine.createSpy(),
|
||||||
reject: jasmine.createSpy()
|
reject: jasmine.createSpy()
|
||||||
};
|
};
|
||||||
env.configure({ Promise: myLibrary });
|
env.configure({ Promise: myLibrary });
|
||||||
|
expect(env.deprecated).toHaveBeenCalledWith(
|
||||||
|
'The `Promise` config property is deprecated. Future versions of ' +
|
||||||
|
'Jasmine will create native promises even if the `Promise` config ' +
|
||||||
|
'property is set. Please remove it.'
|
||||||
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('cannot be configured with an invalid promise library', function() {
|
it('cannot be configured with an invalid promise library', function() {
|
||||||
|
|||||||
@@ -271,6 +271,7 @@ describe('Spies', function() {
|
|||||||
reject: jasmine.createSpy()
|
reject: jasmine.createSpy()
|
||||||
};
|
};
|
||||||
customPromise.resolve.and.returnValue('resolved');
|
customPromise.resolve.and.returnValue('resolved');
|
||||||
|
spyOn(env, 'deprecated');
|
||||||
env.configure({ Promise: customPromise });
|
env.configure({ Promise: customPromise });
|
||||||
|
|
||||||
var spy = env.createSpy('foo').and.resolveTo(42);
|
var spy = env.createSpy('foo').and.resolveTo(42);
|
||||||
|
|||||||
@@ -137,6 +137,8 @@ getJasmineRequireObj().Env = function(j$) {
|
|||||||
* @since 3.5.0
|
* @since 3.5.0
|
||||||
* @type function
|
* @type function
|
||||||
* @default undefined
|
* @default undefined
|
||||||
|
* @deprecated In a future version, Jasmine will ignore the Promise config
|
||||||
|
* property and always create native promises instead.
|
||||||
*/
|
*/
|
||||||
Promise: undefined,
|
Promise: undefined,
|
||||||
/**
|
/**
|
||||||
@@ -293,6 +295,11 @@ getJasmineRequireObj().Env = function(j$) {
|
|||||||
typeof configuration.Promise.reject === 'function'
|
typeof configuration.Promise.reject === 'function'
|
||||||
) {
|
) {
|
||||||
customPromise = configuration.Promise;
|
customPromise = configuration.Promise;
|
||||||
|
self.deprecated(
|
||||||
|
'The `Promise` config property is deprecated. Future versions ' +
|
||||||
|
'of Jasmine will create native promises even if the `Promise` ' +
|
||||||
|
'config property is set. Please remove it.'
|
||||||
|
);
|
||||||
} else {
|
} else {
|
||||||
throw new Error(
|
throw new Error(
|
||||||
'Custom promise library missing `resolve`/`reject` functions'
|
'Custom promise library missing `resolve`/`reject` functions'
|
||||||
|
|||||||
Reference in New Issue
Block a user