|
| 1 | +'use strict'; |
| 2 | + |
| 3 | +describe('support test results', function() { |
| 4 | + var expected, version, testName; |
| 5 | + var userAgent = window.navigator.userAgent; |
| 6 | + |
| 7 | + // Support: iOS 8 only |
| 8 | + if (/iPhone OS 10_1\d(?:_\d+)? /.test(userAgent)) { |
| 9 | + // iOS 8 official simulators have broken user agent (containing something like `iPhone OS 10_12_5`, |
| 10 | + // i.e. the macOS version in place of the iOS version) so they'd fall into an incorrect bucket. |
| 11 | + // Fix the user agent there. |
| 12 | + // NOTE: Make sure the above check doesn't catch the real iOS 10! |
| 13 | + userAgent = userAgent.replace(/iPhone OS 10(?:_\d+)+/, 'iPhone OS 8_1'); |
| 14 | + } |
| 15 | + |
| 16 | + if (/edge\//i.test(userAgent)) { |
| 17 | + expected = { |
| 18 | + classes: true, |
| 19 | + fatArrows: true, |
| 20 | + shorthandMethods: true |
| 21 | + }; |
| 22 | + } else if (/msie|trident/i.test(userAgent)) { |
| 23 | + expected = { |
| 24 | + classes: false, |
| 25 | + fatArrows: false, |
| 26 | + shorthandMethods: false |
| 27 | + }; |
| 28 | + } else if (/iphone os [78]_/i.test(userAgent)) { |
| 29 | + expected = { |
| 30 | + classes: false, |
| 31 | + fatArrows: false, |
| 32 | + shorthandMethods: false |
| 33 | + }; |
| 34 | + } else if (/iphone os 9_/i.test(userAgent)) { |
| 35 | + expected = { |
| 36 | + classes: true, |
| 37 | + fatArrows: false, |
| 38 | + shorthandMethods: true |
| 39 | + }; |
| 40 | + } else if (/iphone os/i.test(userAgent)) { |
| 41 | + expected = { |
| 42 | + classes: true, |
| 43 | + fatArrows: true, |
| 44 | + shorthandMethods: true |
| 45 | + }; |
| 46 | + } else if (/android 4\.[0-3]/i.test(userAgent)) { |
| 47 | + expected = { |
| 48 | + classes: false, |
| 49 | + fatArrows: false, |
| 50 | + shorthandMethods: false |
| 51 | + }; |
| 52 | + } else if (/chrome/i.test(userAgent)) { |
| 53 | + // Catches Chrome on Android as well (i.e. the default |
| 54 | + // Android browser on Android >= 4.4). |
| 55 | + expected = { |
| 56 | + classes: true, |
| 57 | + fatArrows: true, |
| 58 | + shorthandMethods: true |
| 59 | + }; |
| 60 | + } else if (/firefox/i.test(userAgent)) { |
| 61 | + version = parseInt(userAgent.match(/firefox\/(\d+)/i)[1], 10); |
| 62 | + expected = { |
| 63 | + classes: version >= 55, |
| 64 | + fatArrows: true, |
| 65 | + shorthandMethods: true |
| 66 | + }; |
| 67 | + } else if (/\b8(?:\.\d+)+ safari/i.test(userAgent)) { |
| 68 | + expected = { |
| 69 | + classes: false, |
| 70 | + fatArrows: false, |
| 71 | + shorthandMethods: false |
| 72 | + }; |
| 73 | + } else if (/\b9(?:\.\d+)+ safari/i.test(userAgent)) { |
| 74 | + expected = { |
| 75 | + classes: true, |
| 76 | + fatArrows: false, |
| 77 | + shorthandMethods: true |
| 78 | + }; |
| 79 | + } else if (/\b\d+(?:\.\d+)+ safari/i.test(userAgent)) { |
| 80 | + expected = { |
| 81 | + classes: true, |
| 82 | + fatArrows: true, |
| 83 | + shorthandMethods: true |
| 84 | + }; |
| 85 | + } |
| 86 | + |
| 87 | + it('should have expected values specified', function() { |
| 88 | + expect(expected).not.toBe(null); |
| 89 | + expect(typeof expected).toBe('object'); |
| 90 | + }); |
| 91 | + |
| 92 | + for (testName in expected) { |
| 93 | + it('should report support.' + testName + ' to be ' + expected[testName], function() { |
| 94 | + expect(support[testName]).toBe(expected[testName]); |
| 95 | + }); |
| 96 | + } |
| 97 | +}); |
0 commit comments