Accept configurations with Promise: undefined.

Fixes Karma and anything else that uses Env#configuration
as a starting point for a Jasmine config.
This commit is contained in:
Steve Gravrock
2019-08-26 15:45:13 -07:00
parent 0449b35f5a
commit 1a63ab4677
3 changed files with 17 additions and 2 deletions

View File

@@ -1081,7 +1081,10 @@ getJasmineRequireObj().Env = function(j$) {
config.hideDisabled = configuration.hideDisabled;
}
if (configuration.hasOwnProperty('Promise')) {
// Don't use hasOwnProperty to check for Promise existence because Promise
// can be initialized to undefined, either explicitly or by using the
// object returned from Env#configuration. In particular, Karma does this.
if (configuration.Promise) {
if (
typeof configuration.Promise.resolve === 'function' &&
typeof configuration.Promise.reject === 'function'

View File

@@ -28,6 +28,10 @@ describe('Env', function() {
});
});
it('accepts its own current configureation', function() {
env.configure(env.configuration());
});
it('can configure specs to throw errors on expectation failures', function() {
env.configure({ oneFailurePerSpec: true });
@@ -53,6 +57,11 @@ describe('Env', function() {
});
describe('promise library', function() {
it('can be configured without a custom library', function() {
env.configure({});
env.configure({ Promise: undefined });
});
it('can be configured with a custom library', function() {
var myLibrary = {
resolve: jasmine.createSpy(),

View File

@@ -175,7 +175,10 @@ getJasmineRequireObj().Env = function(j$) {
config.hideDisabled = configuration.hideDisabled;
}
if (configuration.hasOwnProperty('Promise')) {
// Don't use hasOwnProperty to check for Promise existence because Promise
// can be initialized to undefined, either explicitly or by using the
// object returned from Env#configuration. In particular, Karma does this.
if (configuration.Promise) {
if (
typeof configuration.Promise.resolve === 'function' &&
typeof configuration.Promise.reject === 'function'