@@ -3,6 +3,7 @@ import {t} from '../../../type';
33import { ModuleType } from '../../../type/classes/ModuleType' ;
44import { CapacityEstimatorCodegen } from '../CapacityEstimatorCodegen' ;
55import { Random } from '../../../random' ;
6+ import { unknown , Value } from '../../../value' ;
67
78describe ( '"any" type' , ( ) => {
89 test ( 'returns the same result as maxEncodingCapacity()' , ( ) => {
@@ -11,6 +12,26 @@ describe('"any" type', () => {
1112 const values = [ null , true , false , 1 , 123.123 , '' , 'adsf' , [ ] , { } , { foo : 'bar' } , [ { a : [ { b : null } ] } ] ] ;
1213 for ( const value of values ) expect ( estimator ( value ) ) . toBe ( maxEncodingCapacity ( value ) ) ;
1314 } ) ;
15+
16+ test ( 'can encode "any" field' , ( ) => {
17+ const type = t . object ( { foo : t . any } ) ;
18+ const estimator = CapacityEstimatorCodegen . get ( type ) ;
19+ expect ( estimator ( { foo : true } ) ) . toBe ( maxEncodingCapacity ( { foo : true } ) ) ;
20+ } ) ;
21+
22+ test ( 'can encode anon Value<unknown>' , ( ) => {
23+ const type = t . object ( { foo : t . any } ) ;
24+ const value = unknown ( 'test' ) ;
25+ const estimator = CapacityEstimatorCodegen . get ( type ) ;
26+ expect ( estimator ( { foo : value } ) ) . toBe ( maxEncodingCapacity ( { foo : value . data } ) ) ;
27+ } ) ;
28+
29+ test ( 'can encode typed Value<T>' , ( ) => {
30+ const type = t . object ( { foo : t . any } ) ;
31+ const value = new Value ( 123 , t . con ( 123 ) ) ;
32+ const estimator = CapacityEstimatorCodegen . get ( type ) ;
33+ expect ( estimator ( { foo : value } ) ) . toBe ( maxEncodingCapacity ( { foo : value . data } ) ) ;
34+ } ) ;
1435} ) ;
1536
1637describe ( '"con" type' , ( ) => {
0 commit comments