|
1 | 1 | 'use strict'; |
2 | 2 |
|
| 3 | +/* globals support: false */ |
| 4 | + |
3 | 5 | describe('injector', function() { |
4 | 6 | var providers; |
5 | 7 | var injector; |
@@ -247,42 +249,47 @@ describe('injector', function() { |
247 | 249 | }); |
248 | 250 |
|
249 | 251 |
|
250 | | - // Only Chrome and Firefox support this syntax. |
251 | | - if (/chrome|firefox/i.test(navigator.userAgent)) { |
252 | | - describe('es6', function() { |
253 | | - /*jshint -W061 */ |
| 252 | + describe('es6', function() { |
| 253 | + /*jshint -W061 */ |
| 254 | + if (support.ES6Function) { |
254 | 255 | // The functions are generated using `eval` as just having the ES6 syntax can break some browsers. |
255 | 256 | it('should be possible to annotate functions that are declared using ES6 syntax', function() { |
256 | 257 | expect(annotate(eval('({ fn(x) { return; } })').fn)).toEqual(['x']); |
257 | 258 | }); |
| 259 | + } |
258 | 260 |
|
259 | 261 |
|
| 262 | + if (support.fatArrow) { |
260 | 263 | it('should create $inject for arrow functions', function() { |
261 | 264 | expect(annotate(eval('(a, b) => a'))).toEqual(['a', 'b']); |
262 | 265 | }); |
| 266 | + } |
263 | 267 |
|
264 | 268 |
|
| 269 | + if (support.fatArrow) { |
265 | 270 | it('should create $inject for arrow functions with no parenthesis', function() { |
266 | 271 | expect(annotate(eval('a => a'))).toEqual(['a']); |
267 | 272 | }); |
| 273 | + } |
268 | 274 |
|
269 | 275 |
|
| 276 | + if (support.fatArrow) { |
270 | 277 | it('should take args before first arrow', function() { |
271 | 278 | expect(annotate(eval('a => b => b'))).toEqual(['a']); |
272 | 279 | }); |
| 280 | + } |
273 | 281 |
|
| 282 | + if (support.classes) { |
274 | 283 | it('should be possible to instantiate ES6 classes', function() { |
275 | | - // Only Chrome (not even the FF we use) supports ES6 classes. |
276 | | - if (!/chrome/i.test(navigator.userAgent)) return; |
277 | 284 | providers('a', function() { return 'a-value'; }); |
278 | 285 | var clazz = eval('(class { constructor(a) { this.a = a; } aVal() { return this.a; } })'); |
279 | 286 | var instance = injector.instantiate(clazz); |
280 | 287 | expect(instance).toEqual({a: 'a-value'}); |
281 | 288 | expect(instance.aVal()).toEqual('a-value'); |
282 | 289 | }); |
283 | | - /*jshint +W061 */ |
284 | | - }); |
285 | | - } |
| 290 | + } |
| 291 | + /*jshint +W061 */ |
| 292 | + }); |
286 | 293 |
|
287 | 294 |
|
288 | 295 | it('should publish annotate API', function() { |
|
0 commit comments