@@ -21,33 +21,49 @@ import { VectorValue } from '../../../src';
2121
2222describe ( 'VectorValue' , ( ) => {
2323 it ( 'fromJSON reconstructs the value from toJSON' , ( ) => {
24- const num : number [ ] = [ 1 , 2 , 3 ] ;
24+ const num : number [ ] = [ 1 , 2 , 3 ] ;
2525 const vectorValue = new VectorValue ( num ) ;
2626 const json = vectorValue . toJSON ( ) ;
2727 const parsedVectorValue = VectorValue . fromJSON ( json ) ;
2828 expect ( vectorValue . isEqual ( parsedVectorValue ) ) . to . be . true ;
2929 } ) ;
30-
30+
3131 it ( 'fromJSON parameter order does not matter' , ( ) => {
3232 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 ;
3640 } ) ;
3741
3842 it ( 'fromJSON empty array does not throw' , ( ) => {
3943 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 ;
4248 } ) ;
4349
4450 it ( 'fromJSON missing fields throws' , ( ) => {
4551 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+ } ) ;
5268 } ) ;
5369} ) ;
0 commit comments