@@ -74,6 +74,60 @@ void main() {
7474 }
7575 return JSObject ();
7676 }.toJS;
77+ mockClient['getTreatmentsByFlagSet' ] =
78+ (JSAny ? flagSetName, JSAny ? attributes, JSAny ? evaluationOptions) {
79+ calls.add ((
80+ methodName: 'getTreatmentsByFlagSet' ,
81+ methodArguments: [flagSetName, attributes, evaluationOptions]
82+ ));
83+ final result = JSObject ();
84+ result.setProperty ('split1' .toJS, 'on' .toJS);
85+ result.setProperty ('split2' .toJS, 'on' .toJS);
86+ return result;
87+ }.toJS;
88+ mockClient['getTreatmentsByFlagSets' ] =
89+ (JSAny ? flagSetNames, JSAny ? attributes, JSAny ? evaluationOptions) {
90+ calls.add ((
91+ methodName: 'getTreatmentsByFlagSets' ,
92+ methodArguments: [flagSetNames, attributes, evaluationOptions]
93+ ));
94+ final result = JSObject ();
95+ result.setProperty ('split1' .toJS, 'on' .toJS);
96+ result.setProperty ('split2' .toJS, 'on' .toJS);
97+ return result;
98+ }.toJS;
99+ mockClient['getTreatmentsWithConfigByFlagSet' ] =
100+ (JSAny ? flagSetName, JSAny ? attributes, JSAny ? evaluationOptions) {
101+ calls.add ((
102+ methodName: 'getTreatmentsWithConfigByFlagSet' ,
103+ methodArguments: [flagSetName, attributes, evaluationOptions]
104+ ));
105+
106+ final treatmentWithConfig = JSObject ();
107+ treatmentWithConfig.setProperty ('treatment' .toJS, 'on' .toJS);
108+ treatmentWithConfig.setProperty ('config' .toJS, 'some-config' .toJS);
109+
110+ final result = JSObject ();
111+ result.setProperty ('split1' .toJS, treatmentWithConfig);
112+ result.setProperty ('split2' .toJS, treatmentWithConfig);
113+ return result;
114+ }.toJS;
115+ mockClient['getTreatmentsWithConfigByFlagSets' ] =
116+ (JSAny ? flagSetNames, JSAny ? attributes, JSAny ? evaluationOptions) {
117+ calls.add ((
118+ methodName: 'getTreatmentsWithConfigByFlagSets' ,
119+ methodArguments: [flagSetNames, attributes, evaluationOptions]
120+ ));
121+
122+ final treatmentWithConfig = JSObject ();
123+ treatmentWithConfig.setProperty ('treatment' .toJS, 'on' .toJS);
124+ treatmentWithConfig.setProperty ('config' .toJS, 'some-config' .toJS);
125+
126+ final result = JSObject ();
127+ result.setProperty ('split1' .toJS, treatmentWithConfig);
128+ result.setProperty ('split2' .toJS, treatmentWithConfig);
129+ return result;
130+ }.toJS;
77131
78132 final mockLog = JSObject ();
79133 mockLog['warn' ] = (JSAny ? arg1) {
@@ -317,6 +371,146 @@ void main() {
317371 {}
318372 ]);
319373 });
374+
375+ test ('getTreatmentsByFlagSet without attributes' , () async {
376+ final result = await _platform.getTreatmentsByFlagSet (
377+ matchingKey: 'matching-key' ,
378+ bucketingKey: 'bucketing-key' ,
379+ flagSet: 'set_1' );
380+
381+ expect (result, {'split1' : 'on' , 'split2' : 'on' });
382+ expect (calls.last.methodName, 'getTreatmentsByFlagSet' );
383+ expect (calls.last.methodArguments.map (jsAnyToDart), ['set_1' , {}, {}]);
384+ });
385+
386+ test ('getTreatmentsByFlagSet with attributes' , () async {
387+ final result = await _platform.getTreatmentsByFlagSet (
388+ matchingKey: 'matching-key' ,
389+ bucketingKey: 'bucketing-key' ,
390+ flagSet: 'set_1' ,
391+ attributes: {'attr1' : true });
392+
393+ expect (result, {'split1' : 'on' , 'split2' : 'on' });
394+ expect (calls.last.methodName, 'getTreatmentsByFlagSet' );
395+ expect (calls.last.methodArguments.map (jsAnyToDart), [
396+ 'set_1' ,
397+ {'attr1' : true },
398+ {}
399+ ]);
400+ });
401+
402+ test ('getTreatmentsByFlagSets without attributes' , () async {
403+ final result = await _platform.getTreatmentsByFlagSets (
404+ matchingKey: 'matching-key' ,
405+ bucketingKey: 'bucketing-key' ,
406+ flagSets: ['set_1' , 'set_2' ]);
407+
408+ expect (result, {'split1' : 'on' , 'split2' : 'on' });
409+ expect (calls.last.methodName, 'getTreatmentsByFlagSets' );
410+ expect (calls.last.methodArguments.map (jsAnyToDart), [
411+ ['set_1' , 'set_2' ],
412+ {},
413+ {}
414+ ]);
415+ });
416+
417+ test ('getTreatmentsByFlagSets with attributes' , () async {
418+ final result = await _platform.getTreatmentsByFlagSets (
419+ matchingKey: 'matching-key' ,
420+ bucketingKey: 'bucketing-key' ,
421+ flagSets: ['set_1' , 'set_2' ],
422+ attributes: {'attr1' : true });
423+
424+ expect (result, {'split1' : 'on' , 'split2' : 'on' });
425+ expect (calls.last.methodName, 'getTreatmentsByFlagSets' );
426+ expect (calls.last.methodArguments.map (jsAnyToDart), [
427+ ['set_1' , 'set_2' ],
428+ {'attr1' : true },
429+ {}
430+ ]);
431+ });
432+
433+ test ('getTreatmentsWithConfigByFlagSet without attributes' , () async {
434+ final result = await _platform.getTreatmentsWithConfigByFlagSet (
435+ matchingKey: 'matching-key' ,
436+ bucketingKey: 'bucketing-key' ,
437+ flagSet: 'set_1' );
438+
439+ expect (result, predicate <Map <String , SplitResult >>((result) {
440+ return result.length == 2 &&
441+ result['split1' ].toString () ==
442+ SplitResult ('on' , 'some-config' ).toString () &&
443+ result['split2' ].toString () ==
444+ SplitResult ('on' , 'some-config' ).toString ();
445+ }));
446+ expect (calls.last.methodName, 'getTreatmentsWithConfigByFlagSet' );
447+ expect (calls.last.methodArguments.map (jsAnyToDart), ['set_1' , {}, {}]);
448+ });
449+
450+ test ('getTreatmentsWithConfigByFlagSet with attributes' , () async {
451+ final result = await _platform.getTreatmentsWithConfigByFlagSet (
452+ matchingKey: 'matching-key' ,
453+ bucketingKey: 'bucketing-key' ,
454+ flagSet: 'set_1' ,
455+ attributes: {'attr1' : true });
456+
457+ expect (result, predicate <Map <String , SplitResult >>((result) {
458+ return result.length == 2 &&
459+ result['split1' ].toString () ==
460+ SplitResult ('on' , 'some-config' ).toString () &&
461+ result['split2' ].toString () ==
462+ SplitResult ('on' , 'some-config' ).toString ();
463+ }));
464+ expect (calls.last.methodName, 'getTreatmentsWithConfigByFlagSet' );
465+ expect (calls.last.methodArguments.map (jsAnyToDart), [
466+ 'set_1' ,
467+ {'attr1' : true },
468+ {}
469+ ]);
470+ });
471+
472+ test ('getTreatmentsWithConfigByFlagSets without attributes' , () async {
473+ final result = await _platform.getTreatmentsWithConfigByFlagSets (
474+ matchingKey: 'matching-key' ,
475+ bucketingKey: 'bucketing-key' ,
476+ flagSets: ['set_1' , 'set_2' ]);
477+
478+ expect (result, predicate <Map <String , SplitResult >>((result) {
479+ return result.length == 2 &&
480+ result['split1' ].toString () ==
481+ SplitResult ('on' , 'some-config' ).toString () &&
482+ result['split2' ].toString () ==
483+ SplitResult ('on' , 'some-config' ).toString ();
484+ }));
485+ expect (calls.last.methodName, 'getTreatmentsWithConfigByFlagSets' );
486+ expect (calls.last.methodArguments.map (jsAnyToDart), [
487+ ['set_1' , 'set_2' ],
488+ {},
489+ {}
490+ ]);
491+ });
492+
493+ test ('getTreatmentsWithConfigByFlagSets with attributes' , () async {
494+ final result = await _platform.getTreatmentsWithConfigByFlagSets (
495+ matchingKey: 'matching-key' ,
496+ bucketingKey: 'bucketing-key' ,
497+ flagSets: ['set_1' , 'set_2' ],
498+ attributes: {'attr1' : true });
499+
500+ expect (result, predicate <Map <String , SplitResult >>((result) {
501+ return result.length == 2 &&
502+ result['split1' ].toString () ==
503+ SplitResult ('on' , 'some-config' ).toString () &&
504+ result['split2' ].toString () ==
505+ SplitResult ('on' , 'some-config' ).toString ();
506+ }));
507+ expect (calls.last.methodName, 'getTreatmentsWithConfigByFlagSets' );
508+ expect (calls.last.methodArguments.map (jsAnyToDart), [
509+ ['set_1' , 'set_2' ],
510+ {'attr1' : true },
511+ {}
512+ ]);
513+ });
320514 });
321515
322516 group ('initialization' , () {
0 commit comments