Skip to content

Commit 0607db9

Browse files
committed
add tests for typed arrays
1 parent 2e322a0 commit 0607db9

File tree

3 files changed

+13
-1
lines changed

3 files changed

+13
-1
lines changed

src/helpers/helpers.core.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@ var helpers = {
3939
*/
4040
isArray: function(value) {
4141
var type = Object.prototype.toString.call(value);
42-
// Typed array
4342
if (type.substr(0, 7) === '[object' && type.substr(-6) === 'Array]') {
4443
return true;
4544
}

test/.eslintrc.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
1+
parserOptions:
2+
ecmaVersion: 5 # don't rely on default, since its changed by env: es6
3+
14
env:
5+
es6: true # also changes default ecmaVersion to 6
26
jasmine: true
37

48
globals:

test/specs/helpers.core.tests.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,15 @@ describe('Chart.helpers.core', function() {
2121
expect(helpers.isArray([42])).toBeTruthy();
2222
expect(helpers.isArray(new Array())).toBeTruthy();
2323
expect(helpers.isArray(Array.prototype)).toBeTruthy();
24+
expect(helpers.isArray(new Int8Array(2))).toBeTruthy();
25+
expect(helpers.isArray(new Uint8Array())).toBeTruthy();
26+
expect(helpers.isArray(new Uint8ClampedArray([128, 244]))).toBeTruthy();
27+
expect(helpers.isArray(new Int16Array())).toBeTruthy();
28+
expect(helpers.isArray(new Uint16Array())).toBeTruthy();
29+
expect(helpers.isArray(new Int32Array())).toBeTruthy();
30+
expect(helpers.isArray(new Uint32Array())).toBeTruthy();
31+
expect(helpers.isArray(new Float32Array([1.2]))).toBeTruthy();
32+
expect(helpers.isArray(new Float64Array([]))).toBeTruthy();
2433
});
2534
it('should return false if value is not an array', function() {
2635
expect(helpers.isArray()).toBeFalsy();

0 commit comments

Comments
 (0)