Skip to content

Commit 99ca907

Browse files
Tests: Add checks for polyfills (for IE Jasmine).
1 parent b29295e commit 99ca907

File tree

2 files changed

+62
-1
lines changed

2 files changed

+62
-1
lines changed

tests.html

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
charset="utf-8"></script>
1616
<script src="static/js/jquery-2.1.4.min.js"></script>
1717
<script src="static/js/jquery.browser.min.js"></script>
18-
<script src="static/js/microbit-fs.umd.js"></script>
18+
<script src="static/js/microbit-fs.umd.min.js"></script>
1919
<script src="js/micropythonapi.js"></script>
2020
<script src="js/urlparser.js"></script>
2121
<script src="js/fs.js"></script>
@@ -27,5 +27,6 @@
2727
<script src="tests/spec/urlparser-spec.js"></script>
2828
<script src="tests/spec/fs-spec.js"></script>
2929
<script src="tests/spec/micropythonapi-spec.js"></script>
30+
<script src="tests/spec/polyfill-spec.js"></script>
3031
</body>
3132
</html>

tests/spec/polyfill-spec.js

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
/**
2+
* The goal of this spec file is to test in Internet Explorer via Jasmin
3+
* tests.html file a few of the polyfills we know are used in the editor.
4+
* These are mostly coming via microbit-fs library.
5+
*
6+
* In the past the build pipeline has somehow failed to include some of the
7+
* polyfills (in one case the minifier has also affected this). So having a
8+
* few tests here as a sanity check.
9+
*
10+
* Useful links:
11+
* https://kangax.github.io/compat-table/es6/
12+
* https://caniuse.com/?search=es6
13+
*/
14+
15+
describe("Check (some) ES6 features work.", function() {
16+
/* Currently not used in microbit-fs
17+
it("String.prototype.startsWith()", function() {
18+
expect('random string'.startsWith('random')).toBeTruthy();
19+
});
20+
*/
21+
it("String.prototype.endsWith()", function() {
22+
expect('random string'.endsWith('string')).toBeTruthy();
23+
});
24+
25+
it("String.prototype.includes()", function() {
26+
expect('random string'.includes('m s')).toBeTruthy();
27+
});
28+
29+
it("isNaN()", function() {
30+
expect(isNaN('100F')).toBeTruthy();
31+
});
32+
/* Currently not used in microbit-fs
33+
it("Number.parseInt()", function() {
34+
expect(Number.parseInt(' 0xF', 16)).toEqual(15);
35+
});
36+
*/
37+
it("Array.prototype.fill()", function() {
38+
var array1 = [1, 2, 3, 4];
39+
array1.fill(0, 2, 4)
40+
expect(array1).toEqual([1, 2, 0, 0]);
41+
});
42+
/* Currently not used in microbit-fs
43+
it("Array.prototype.find()", function() {
44+
var array1 = [5, 12, 8, 130, 44];
45+
var found = array1.find(function(element) {
46+
return element > 10
47+
});
48+
expect(found).toEqual(12);
49+
});
50+
*/
51+
/* Currently not used in microbit-fs
52+
it("Array.prototype.findIndex()", function() {
53+
var array1 = [5, 12, 8, 130, 44];
54+
var isLargeNumber = array1.findIndex(function(element) {
55+
return element > 13
56+
});
57+
expect(isLargeNumber).toEqual(3);
58+
});
59+
*/
60+
});

0 commit comments

Comments
 (0)