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.
This commit is contained in:
Martin Staffa
2018-01-10 15:31:33 +01:00
committed by Martin Staffa
parent 6388a348e4
commit 8510143a0e
2 changed files with 4 additions and 4 deletions
+2 -2
View File
@@ -2922,13 +2922,13 @@ describe('ngOptions', function() {
});
// Support: Safari 9
// Support: Safari 9+
// This test relies defining a getter/setter `selected` property on either `<option>` elements
// or their prototype. Some browsers (including Safari 9) are very flakey when the
// getter/setter is not defined on the prototype (probably due to some bug). On Safari 9, the
// getter/setter that is already defined on the `<option>` element's prototype is not
// configurable, so we can't overwrite it with our spy.
if (!/\b9(?:\.\d+)+ safari/i.test(window.navigator.userAgent)) {
if (!/\b(9|\d{2})(?:\.\d+)+ safari/i.test(window.navigator.userAgent)) {
it('should not re-set the `selected` property if it already has the correct value', function() {
scope.values = [{name: 'A'}, {name: 'B'}];
createMultiSelect();
+2 -2
View File
@@ -1007,7 +1007,7 @@ describe('ngMock', function() {
})();
function testCaller() {
return inject(function() {
return inject(function injectableError() {
throw new Error();
});
}
@@ -1019,7 +1019,7 @@ describe('ngMock', function() {
try {
throwErrorFromInjectCallback();
} catch (e) {
expect(e.stack).toMatch('testCaller');
expect(e.stack).toMatch('injectableError');
}
});
});