@webcomponents/webcomponentsjs
Version:
Web Components Polyfills
66 lines (63 loc) • 1.98 kB
HTML
<!--
@license
Copyright (c) 2018 The Polymer Project Authors. All rights reserved.
This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
Code distributed by Google as part of the polymer project is also
subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
-->
<html>
<head>
<title>Symbol Polyfill</title>
<script id="loader" src="../webcomponents-loader.js"></script>
<script src="./wct-config.js"></script>
<script src="../node_modules/wct-browser-legacy/browser.js"></script>
</head>
<body>
<script>
suite('Symbol Polyfill', function() {
test('Symbol exists', function() {
assert.property(window, 'Symbol');
});
test('Symbol.iterator exists', function() {
assert.property(Symbol, 'iterator');
});
test('for-of loop works', function() {
let output = [];
const arr = [1,2,3];
for (const value of arr) {
output.push(value);
}
assert.deepEqual(output, arr);
output.length = 0;
const s = new Set();
s.add(1);
s.add(2);
s.add(3);
for (const value of s) {
output.push(value);
}
assert.deepEqual(output, [1,2,3]);
output.length = 0;
const map = new Map();
map.set(1, 'a');
map.set(2, 'b');
map.set(3, 'c')
for (const entry of map) {
output.push(entry[0]);
output.push(entry[1]);
}
assert.deepEqual(output, [1, 'a', 2, 'b', 3, 'c']);
output.length = 0;
const str = '123';
for (const s of str) {
output.push(s);
}
assert.deepEqual(output, ['1', '2', '3']);
});
})
</script>
</body>
</html>