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