Skip to content

Commit 5b7bced

Browse files
committed
Account for missing URL on GJS
1 parent 7dc6a09 commit 5b7bced

4 files changed

Lines changed: 38 additions & 14 deletions

File tree

lib/jasmine-core/jasmine.js

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -402,13 +402,19 @@ getJasmineRequireObj().base = function(j$, private$, jasmineGlobal) {
402402
);
403403
};
404404

405-
private$.isURL = function(obj) {
406-
return (
407-
obj !== null &&
408-
typeof obj !== 'undefined' &&
409-
obj.constructor === jasmineGlobal.URL
410-
);
411-
};
405+
if (jasmineGlobal.URL) {
406+
private$.isURL = function(obj) {
407+
return (
408+
obj !== null &&
409+
typeof obj !== 'undefined' &&
410+
obj.constructor === jasmineGlobal.URL
411+
);
412+
};
413+
} else {
414+
private$.isURL = function(obj) {
415+
return false;
416+
};
417+
}
412418

413419
private$.isIterable = function(value) {
414420
return value && !!value[Symbol.iterator];

spec/core/baseSpec.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,10 @@ describe('base helpers', function() {
6969

7070
describe('isURL', function() {
7171
it('returns true when the object is a URL', function() {
72+
if (typeof URL === 'undefined') {
73+
pending('URL is not available on this platform');
74+
}
75+
7276
expect(privateUnderTest.isURL(new URL('http://localhost/'))).toBe(true);
7377
});
7478

spec/core/matchers/matchersUtilSpec.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -662,6 +662,10 @@ describe('matchersUtil', function() {
662662
});
663663

664664
it('passes when comparing two identical URLs', function() {
665+
if (typeof URL === 'undefined') {
666+
pending('URL is not available on this platform');
667+
}
668+
665669
const matchersUtil = new privateUnderTest.MatchersUtil();
666670

667671
expect(
@@ -673,6 +677,10 @@ describe('matchersUtil', function() {
673677
});
674678

675679
it('fails when comparing two different URLs', function() {
680+
if (typeof URL === 'undefined') {
681+
pending('URL is not available on this platform');
682+
}
683+
676684
const matchersUtil = new privateUnderTest.MatchersUtil();
677685
const url1 = new URL('http://localhost/1');
678686

src/core/base.js

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -177,13 +177,19 @@ getJasmineRequireObj().base = function(j$, private$, jasmineGlobal) {
177177
);
178178
};
179179

180-
private$.isURL = function(obj) {
181-
return (
182-
obj !== null &&
183-
typeof obj !== 'undefined' &&
184-
obj.constructor === jasmineGlobal.URL
185-
);
186-
};
180+
if (jasmineGlobal.URL) {
181+
private$.isURL = function(obj) {
182+
return (
183+
obj !== null &&
184+
typeof obj !== 'undefined' &&
185+
obj.constructor === jasmineGlobal.URL
186+
);
187+
};
188+
} else {
189+
private$.isURL = function(obj) {
190+
return false;
191+
};
192+
}
187193

188194
private$.isIterable = function(value) {
189195
return value && !!value[Symbol.iterator];

0 commit comments

Comments
 (0)