1
1
var Lib = require ( '@src/lib' ) ;
2
2
var supplyDefaults = require ( '../assets/supply_defaults' ) ;
3
- var isTypedArray = require ( '../../../src/lib/is_array' ) . isTypedArray ;
4
3
var b64 = require ( 'base64-arraybuffer' ) ;
5
4
var mock1 = require ( '@mocks/typed_array_repr_scatter.json' ) ;
6
5
7
6
var typedArraySpecs = [
8
7
[ 'int8' , new Int8Array ( [ - 128 , - 34 , 1 , 127 ] ) ] ,
9
8
[ 'uint8' , new Uint8Array ( [ 0 , 1 , 127 , 255 ] ) ] ,
9
+ [ 'uint8_clamped' , new Uint8ClampedArray ( [ 0 , 1 , 127 , 255 ] ) ] ,
10
10
[ 'int16' , new Int16Array ( [ - 32768 , - 123 , 345 , 32767 ] ) ] ,
11
11
[ 'uint16' , new Uint16Array ( [ 0 , 345 , 32767 , 65535 ] ) ] ,
12
12
[ 'int32' , new Int32Array ( [ - 2147483648 , - 123 , 345 , 32767 , 2147483647 ] ) ] ,
@@ -21,13 +21,13 @@ describe('Test TypedArray representations', function() {
21
21
describe ( 'ArrayBuffer' , function ( ) {
22
22
it ( 'should accept representation as ArrayBuffer' , function ( ) {
23
23
typedArraySpecs . forEach ( function ( arraySpec ) {
24
- // Build data and confirm its type
25
- var data = arraySpec [ 1 ] . buffer ;
26
- expect ( data . constructor ) . toEqual ( ArrayBuffer ) ;
24
+ // Build value and confirm its type
25
+ var value = arraySpec [ 1 ] . buffer ;
26
+ expect ( value . constructor ) . toEqual ( ArrayBuffer ) ;
27
27
28
28
var repr = {
29
29
dtype : arraySpec [ 0 ] ,
30
- data : data
30
+ value : value
31
31
} ;
32
32
var gd = {
33
33
data : [ {
@@ -46,13 +46,13 @@ describe('Test TypedArray representations', function() {
46
46
describe ( 'Array' , function ( ) {
47
47
it ( 'should accept representation as Array' , function ( ) {
48
48
typedArraySpecs . forEach ( function ( arraySpec ) {
49
- // Build data and confirm its type
50
- var data = Array . prototype . slice . call ( arraySpec [ 1 ] ) ;
51
- expect ( Array . isArray ( data ) ) . toEqual ( true ) ;
49
+ // Build value and confirm its type
50
+ var value = Array . prototype . slice . call ( arraySpec [ 1 ] ) ;
51
+ expect ( Array . isArray ( value ) ) . toEqual ( true ) ;
52
52
53
53
var repr = {
54
54
dtype : arraySpec [ 0 ] ,
55
- data : data
55
+ value : value
56
56
} ;
57
57
var gd = {
58
58
data : [ {
@@ -71,13 +71,13 @@ describe('Test TypedArray representations', function() {
71
71
describe ( 'DataView' , function ( ) {
72
72
it ( 'should accept representation as DataView' , function ( ) {
73
73
typedArraySpecs . forEach ( function ( arraySpec ) {
74
- // Build data and confirm its type
75
- var data = new DataView ( arraySpec [ 1 ] . buffer ) ;
76
- expect ( data . constructor ) . toEqual ( DataView ) ;
74
+ // Build value and confirm its type
75
+ var value = new DataView ( arraySpec [ 1 ] . buffer ) ;
76
+ expect ( value . constructor ) . toEqual ( DataView ) ;
77
77
78
78
var repr = {
79
79
dtype : arraySpec [ 0 ] ,
80
- data : data
80
+ value : value
81
81
} ;
82
82
var gd = {
83
83
data : [ {
@@ -96,13 +96,13 @@ describe('Test TypedArray representations', function() {
96
96
describe ( 'base64' , function ( ) {
97
97
it ( 'should accept representation as base 64 string' , function ( ) {
98
98
typedArraySpecs . forEach ( function ( arraySpec ) {
99
- // Build data and confirm its type
100
- var data = b64 . encode ( arraySpec [ 1 ] . buffer ) ;
101
- expect ( typeof data ) . toEqual ( 'string' ) ;
99
+ // Build value and confirm its type
100
+ var value = b64 . encode ( arraySpec [ 1 ] . buffer ) ;
101
+ expect ( typeof value ) . toEqual ( 'string' ) ;
102
102
103
103
var repr = {
104
104
dtype : arraySpec [ 0 ] ,
105
- data : data
105
+ value : value
106
106
} ;
107
107
var gd = {
108
108
data : [ {
@@ -127,21 +127,21 @@ describe('Test TypedArray representations', function() {
127
127
// data_array property
128
128
expect ( gd . data [ 0 ] . x ) . toEqual ( {
129
129
'dtype' : 'float64' ,
130
- 'data ' : [ 3 , 2 , 1 ] } ) ;
130
+ 'value ' : [ 3 , 2 , 1 ] } ) ;
131
131
expect ( gd . _fullData [ 0 ] . x ) . toEqual ( new Float64Array ( [ 3 , 2 , 1 ] ) ) ;
132
132
133
133
// Check y
134
134
// data_array property
135
135
expect ( gd . data [ 0 ] . y ) . toEqual ( {
136
136
'dtype' : 'float32' ,
137
- 'data ' : 'AABAQAAAAEAAAIA/' } ) ;
137
+ 'value ' : 'AABAQAAAAEAAAIA/' } ) ;
138
138
expect ( gd . _fullData [ 0 ] . y ) . toEqual ( new Float32Array ( [ 3 , 2 , 1 ] ) ) ;
139
139
140
140
// Check marker.color
141
141
// This is an arrayOk property not a data_array property
142
142
expect ( gd . data [ 0 ] . marker . color ) . toEqual ( {
143
143
'dtype' : 'uint16' ,
144
- 'data ' : 'AwACAAEA' } ) ;
144
+ 'value ' : 'AwACAAEA' } ) ;
145
145
expect ( gd . _fullData [ 0 ] . marker . color ) . toEqual ( new Uint16Array ( [ 3 , 2 , 1 ] ) ) ;
146
146
} ) ;
147
147
} ) ;
0 commit comments