@@ -6,6 +6,7 @@ import 'package:splitio_web/splitio_web.dart';
66import 'package:splitio_web/src/js_interop.dart' ;
77import 'package:splitio_platform_interface/split_certificate_pinning_configuration.dart' ;
88import 'package:splitio_platform_interface/split_configuration.dart' ;
9+ import 'package:splitio_platform_interface/split_evaluation_options.dart' ;
910import 'package:splitio_platform_interface/split_sync_config.dart' ;
1011import 'package:splitio_platform_interface/split_rollout_cache_configuration.dart' ;
1112import 'utils/js_interop_test_utils.dart' ;
@@ -84,8 +85,8 @@ void main() {
8485 'attrDouble' : 1.1 ,
8586 'attrList' : ['value1' , 100 , false ],
8687 'attrSet' : {'value3' , 100 , true },
87- 'attrNull' : null , // ignored
88- 'attrInvalid ' : {'value5' : true } // ignored
88+ 'attrNull' : null , // not valid attribute value
89+ 'attrMap ' : {'value5' : true } // not valid attribute value
8990 });
9091
9192 expect (result, 'on' );
@@ -108,13 +109,68 @@ void main() {
108109 expect (
109110 jsAnyToDart (calls[calls.length - 2 ].methodArguments[0 ]),
110111 equals (
111- 'Invalid attribute value: {value5: true}, for key: attrInvalid , will be ignored' ));
112+ 'Invalid attribute value: {value5: true}, for key: attrMap , will be ignored' ));
112113 expect (calls[calls.length - 3 ].methodName, 'warn' );
113114 expect (
114115 jsAnyToDart (calls[calls.length - 3 ].methodArguments[0 ]),
115116 equals (
116117 'Invalid attribute value: null, for key: attrNull, will be ignored' ));
117118 });
119+
120+ test ('getTreatment with evaluation properties' , () async {
121+ final result = await _platform.getTreatment (
122+ matchingKey: 'matching-key' ,
123+ bucketingKey: 'bucketing-key' ,
124+ splitName: 'split' ,
125+ evaluationOptions: EvaluationOptions ({
126+ 'propBool' : true ,
127+ 'propString' : 'value' ,
128+ 'propInt' : 1 ,
129+ 'propDouble' : 1.1 ,
130+ 'propList' : ['value1' , 100 , false ], // not valid property value
131+ 'propSet' : {'value3' , 100 , true }, // not valid property value
132+ 'propNull' : null , // not valid property value
133+ 'propMap' : {'value5' : true } // not valid property value
134+ }));
135+
136+ expect (result, 'on' );
137+ expect (calls.last.methodName, 'getTreatment' );
138+ expect (calls.last.methodArguments.map (jsAnyToDart), [
139+ 'split' ,
140+ {},
141+ {
142+ 'properties' : {
143+ 'propBool' : true ,
144+ 'propString' : 'value' ,
145+ 'propInt' : 1 ,
146+ 'propDouble' : 1.1 ,
147+ }
148+ }
149+ ]);
150+
151+ // assert warnings
152+ expect (calls[calls.length - 2 ].methodName, 'warn' );
153+ expect (
154+ jsAnyToDart (calls[calls.length - 2 ].methodArguments[0 ]),
155+ equals (
156+ 'Invalid property value: {value5: true}, for key: propMap, will be ignored' ));
157+ expect (calls[calls.length - 3 ].methodName, 'warn' );
158+ expect (
159+ jsAnyToDart (calls[calls.length - 3 ].methodArguments[0 ]),
160+ equals (
161+ 'Invalid property value: null, for key: propNull, will be ignored' ));
162+ expect (calls[calls.length - 4 ].methodName, 'warn' );
163+ expect (
164+ jsAnyToDart (calls[calls.length - 4 ].methodArguments[0 ]),
165+ equals (
166+ 'Invalid property value: {value3, 100, true}, for key: propSet, will be ignored' ));
167+ expect (calls[calls.length - 5 ].methodName, 'warn' );
168+ expect (
169+ jsAnyToDart (calls[calls.length - 5 ].methodArguments[0 ]),
170+ equals (
171+ 'Invalid property value: [value1, 100, false], for key: propList, will be ignored' ));
172+ });
173+
118174 });
119175
120176 group ('initialization' , () {
0 commit comments