Skip to content

Commit

Permalink
add tests for typed arrays
Browse files Browse the repository at this point in the history
  • Loading branch information
kurkle committed Dec 12, 2018
1 parent 2e322a0 commit 0607db9
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
1 change: 0 additions & 1 deletion src/helpers/helpers.core.js
Expand Up @@ -39,7 +39,6 @@ var helpers = {
*/
isArray: function(value) {
var type = Object.prototype.toString.call(value);
// Typed array
if (type.substr(0, 7) === '[object' && type.substr(-6) === 'Array]') {
return true;
}
Expand Down
4 changes: 4 additions & 0 deletions test/.eslintrc.yml
@@ -1,4 +1,8 @@
parserOptions:
ecmaVersion: 5 # don't rely on default, since its changed by env: es6

env:
es6: true # also changes default ecmaVersion to 6
jasmine: true

globals:
Expand Down
9 changes: 9 additions & 0 deletions test/specs/helpers.core.tests.js
Expand Up @@ -21,6 +21,15 @@ describe('Chart.helpers.core', function() {
expect(helpers.isArray([42])).toBeTruthy();
expect(helpers.isArray(new Array())).toBeTruthy();
expect(helpers.isArray(Array.prototype)).toBeTruthy();
expect(helpers.isArray(new Int8Array(2))).toBeTruthy();
expect(helpers.isArray(new Uint8Array())).toBeTruthy();
expect(helpers.isArray(new Uint8ClampedArray([128, 244]))).toBeTruthy();
expect(helpers.isArray(new Int16Array())).toBeTruthy();
expect(helpers.isArray(new Uint16Array())).toBeTruthy();
expect(helpers.isArray(new Int32Array())).toBeTruthy();
expect(helpers.isArray(new Uint32Array())).toBeTruthy();
expect(helpers.isArray(new Float32Array([1.2]))).toBeTruthy();
expect(helpers.isArray(new Float64Array([]))).toBeTruthy();
});
it('should return false if value is not an array', function() {
expect(helpers.isArray()).toBeFalsy();
Expand Down

0 comments on commit 0607db9

Please sign in to comment.