@@ -21,33 +21,49 @@ import { VectorValue } from '../../../src';
21
21
22
22
describe ( 'VectorValue' , ( ) => {
23
23
it ( 'fromJSON reconstructs the value from toJSON' , ( ) => {
24
- const num : number [ ] = [ 1 , 2 , 3 ] ;
24
+ const num : number [ ] = [ 1 , 2 , 3 ] ;
25
25
const vectorValue = new VectorValue ( num ) ;
26
26
const json = vectorValue . toJSON ( ) ;
27
27
const parsedVectorValue = VectorValue . fromJSON ( json ) ;
28
28
expect ( vectorValue . isEqual ( parsedVectorValue ) ) . to . be . true ;
29
29
} ) ;
30
-
30
+
31
31
it ( 'fromJSON parameter order does not matter' , ( ) => {
32
32
const type = 'firestore/vectorValue/1.0' ;
33
- const data = [ 1 , 2 , 3 ] ;
34
- expect ( ( ) => { VectorValue . fromJSON ( { data, type} ) ; } ) . to . not . throw ;
35
- expect ( ( ) => { VectorValue . fromJSON ( { type, data} ) ; } ) . to . not . throw ;
33
+ const data = [ 1 , 2 , 3 ] ;
34
+ expect ( ( ) => {
35
+ VectorValue . fromJSON ( { data, type } ) ;
36
+ } ) . to . not . throw ;
37
+ expect ( ( ) => {
38
+ VectorValue . fromJSON ( { type, data } ) ;
39
+ } ) . to . not . throw ;
36
40
} ) ;
37
41
38
42
it ( 'fromJSON empty array does not throw' , ( ) => {
39
43
const type = 'firestore/vectorValue/1.0' ;
40
- const data = [ 1 , 2 , 3 ] ;
41
- expect ( ( ) => { VectorValue . fromJSON ( { type, data} ) ; } ) . to . not . throw ;
44
+ const data = [ 1 , 2 , 3 ] ;
45
+ expect ( ( ) => {
46
+ VectorValue . fromJSON ( { type, data } ) ;
47
+ } ) . to . not . throw ;
42
48
} ) ;
43
49
44
50
it ( 'fromJSON missing fields throws' , ( ) => {
45
51
const type = 'firestore/vectorValue/1.0' ;
46
- const data = [ 1 , 2 , 3 ] ;
47
- expect ( ( ) => { VectorValue . fromJSON ( { type /* missing data */ } ) ; } ) . to . throw ;
48
- expect ( ( ) => { VectorValue . fromJSON ( { data /* missing type */ } ) ; } ) . to . throw ;
49
- expect ( ( ) => { VectorValue . fromJSON ( { type : 1 , data } ) ; } ) . to . throw ;
50
- expect ( ( ) => { VectorValue . fromJSON ( { type : "firestore/bytes/1.0" , data } ) ; } ) . to . throw ;
51
- expect ( ( ) => { VectorValue . fromJSON ( { type, data : "not a number" } ) ; } ) ;
52
+ const data = [ 1 , 2 , 3 ] ;
53
+ expect ( ( ) => {
54
+ VectorValue . fromJSON ( { type /* missing data */ } ) ;
55
+ } ) . to . throw ;
56
+ expect ( ( ) => {
57
+ VectorValue . fromJSON ( { data /* missing type */ } ) ;
58
+ } ) . to . throw ;
59
+ expect ( ( ) => {
60
+ VectorValue . fromJSON ( { type : 1 , data } ) ;
61
+ } ) . to . throw ;
62
+ expect ( ( ) => {
63
+ VectorValue . fromJSON ( { type : 'firestore/bytes/1.0' , data } ) ;
64
+ } ) . to . throw ;
65
+ expect ( ( ) => {
66
+ VectorValue . fromJSON ( { type, data : 'not a number' } ) ;
67
+ } ) ;
52
68
} ) ;
53
69
} ) ;
0 commit comments