Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

Commit 8510143

Browse files
committed
test(*): fix tests for Safari 10+
The mocksSpec change is due to the following issue in Safari 10+ strict mode: In the following code, Safari will not use the name of the enclosing function (testCaller) in the stack, but rather list the anonymous function that is called to inject: ``` function testCaller() { return inject(function() { throw new Error(); }); } var throwErrorFromInjectCallback = testCaller(); ``` Naming the anonymous function allows us to check for it in the test.
1 parent 6388a34 commit 8510143

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

test/ng/directive/ngOptionsSpec.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -2922,13 +2922,13 @@ describe('ngOptions', function() {
29222922
});
29232923

29242924

2925-
// Support: Safari 9
2925+
// Support: Safari 9+
29262926
// This test relies defining a getter/setter `selected` property on either `<option>` elements
29272927
// or their prototype. Some browsers (including Safari 9) are very flakey when the
29282928
// getter/setter is not defined on the prototype (probably due to some bug). On Safari 9, the
29292929
// getter/setter that is already defined on the `<option>` element's prototype is not
29302930
// configurable, so we can't overwrite it with our spy.
2931-
if (!/\b9(?:\.\d+)+ safari/i.test(window.navigator.userAgent)) {
2931+
if (!/\b(9|\d{2})(?:\.\d+)+ safari/i.test(window.navigator.userAgent)) {
29322932
it('should not re-set the `selected` property if it already has the correct value', function() {
29332933
scope.values = [{name: 'A'}, {name: 'B'}];
29342934
createMultiSelect();

test/ngMock/angular-mocksSpec.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -1007,7 +1007,7 @@ describe('ngMock', function() {
10071007
})();
10081008

10091009
function testCaller() {
1010-
return inject(function() {
1010+
return inject(function injectableError() {
10111011
throw new Error();
10121012
});
10131013
}
@@ -1019,7 +1019,7 @@ describe('ngMock', function() {
10191019
try {
10201020
throwErrorFromInjectCallback();
10211021
} catch (e) {
1022-
expect(e.stack).toMatch('testCaller');
1022+
expect(e.stack).toMatch('injectableError');
10231023
}
10241024
});
10251025
});

0 commit comments

Comments
 (0)