@@ -4,6 +4,7 @@ import 'package:web/web.dart' as web;
44import 'package:flutter_test/flutter_test.dart' ;
55import 'package:splitio_web/splitio_web.dart' ;
66import 'package:splitio_web/src/js_interop.dart' ;
7+ import 'package:splitio_platform_interface/split_certificate_pinning_configuration.dart' ;
78import 'package:splitio_platform_interface/split_configuration.dart' ;
89import 'package:splitio_platform_interface/split_sync_config.dart' ;
910import 'package:splitio_platform_interface/split_rollout_cache_configuration.dart' ;
@@ -15,19 +16,25 @@ extension on web.Window {
1516}
1617
1718void main () {
18- String methodName = '' ;
19- dynamic methodArguments;
19+ final List <({String methodName, List <dynamic > methodArguments})> calls = [];
2020
21- setUp (() {
22- final mockFactory = JSObject ();
21+ final mockLog = JSObject ();
22+ mockLog['warn' ] = (JSAny ? arg1) {
23+ calls.add ((methodName: 'warn' , methodArguments: [arg1]));
24+ }.toJS;
25+ final mockSettings = JSObject ();
26+ mockSettings['log' ] = mockLog;
27+
28+ final mockFactory = JSObject ();
29+ mockFactory['settings' ] = mockSettings;
2330
24- final mockSplitio = JSObject ();
25- mockSplitio['SplitFactory' ] = (JSAny ? arg1) {
26- methodName = 'SplitFactory' ;
27- methodArguments = [arg1];
28- return mockFactory;
29- }.toJS;
31+ final mockSplitio = JSObject ();
32+ mockSplitio['SplitFactory' ] = (JSAny ? arg1) {
33+ calls.add ((methodName: 'SplitFactory' , methodArguments: [arg1]));
34+ return mockFactory;
35+ }.toJS;
3036
37+ setUp (() {
3138 (web.window as JSObject ).setProperty ('splitio' .toJS, mockSplitio);
3239 });
3340
@@ -38,9 +45,9 @@ void main() {
3845 await _platform.init (
3946 apiKey: 'api-key' , matchingKey: 'matching-key' , bucketingKey: null );
4047
41- expect (methodName, 'SplitFactory' );
48+ expect (calls.last. methodName, 'SplitFactory' );
4249 expect (
43- jsObjectToMap (methodArguments[0 ]),
50+ jsObjectToMap (calls.last. methodArguments[0 ]),
4451 equals ({
4552 'core' : {
4653 'authorizationKey' : 'api-key' ,
@@ -57,9 +64,9 @@ void main() {
5764 matchingKey: 'matching-key' ,
5865 bucketingKey: 'bucketing-key' );
5966
60- expect (methodName, 'SplitFactory' );
67+ expect (calls.last. methodName, 'SplitFactory' );
6168 expect (
62- jsObjectToMap (methodArguments[0 ]),
69+ jsObjectToMap (calls.last. methodArguments[0 ]),
6370 equals ({
6471 'core' : {
6572 'authorizationKey' : 'api-key' ,
@@ -80,9 +87,9 @@ void main() {
8087 bucketingKey: 'bucketing-key' ,
8188 sdkConfiguration: SplitConfiguration ());
8289
83- expect (methodName, 'SplitFactory' );
90+ expect (calls.last. methodName, 'SplitFactory' );
8491 expect (
85- jsObjectToMap (methodArguments[0 ]),
92+ jsObjectToMap (calls.last. methodArguments[0 ]),
8693 equals ({
8794 'core' : {
8895 'authorizationKey' : 'api-key' ,
@@ -101,7 +108,6 @@ void main() {
101108 }));
102109 });
103110
104- // @TODO validate warning for unsupported config options
105111 // @TODO validate full config with pluggable Browser SDK modules
106112 test ('init with config: full config' , () async {
107113 SplitioWeb _platform = SplitioWeb ();
@@ -118,11 +124,11 @@ void main() {
118124 eventsQueueSize: 5 ,
119125 impressionsQueueSize: 6 ,
120126 eventFlushInterval: 7 ,
121- // eventsPerPush: 8, // unsupported in Web
127+ eventsPerPush: 8 , // unsupported in Web
122128 trafficType: 'user' ,
123129 enableDebug: false , // deprecated, logLevel has precedence
124130 streamingEnabled: false ,
125- // persistentAttributesEnabled: true, // unsupported in Web
131+ persistentAttributesEnabled: true , // unsupported in Web
126132 impressionListener: true ,
127133 sdkEndpoint: 'sdk-endpoint' ,
128134 eventsEndpoint: 'events-endpoint' ,
@@ -134,19 +140,19 @@ void main() {
134140 impressionsMode: ImpressionsMode .none,
135141 syncEnabled: true ,
136142 userConsent: UserConsent .granted,
137- // encryptionEnabled: true, // unsupported in Web
143+ encryptionEnabled: true , // unsupported in Web
138144 logLevel: SplitLogLevel .info,
139145 readyTimeout: 1 ,
140- // certificatePinningConfiguration:
141- // CertificatePinningConfiguration( ), // unsupported in Web
146+ certificatePinningConfiguration: CertificatePinningConfiguration ()
147+ . addPin ( 'host' , 'pin' ), // unsupported in Web
142148 rolloutCacheConfiguration: RolloutCacheConfiguration (
143149 expirationDays: 100 ,
144150 clearOnInit: true ,
145151 )));
146152
147- expect (methodName, 'SplitFactory' );
153+ expect (calls[calls.length - 5 ]. methodName, 'SplitFactory' );
148154 expect (
149- jsObjectToMap (methodArguments[0 ]),
155+ jsObjectToMap (calls[calls.length - 5 ]. methodArguments[0 ]),
150156 equals ({
151157 'core' : {
152158 'authorizationKey' : 'api-key' ,
@@ -197,6 +203,30 @@ void main() {
197203 'clearOnInit' : true
198204 }
199205 }));
206+
207+ expect (calls[calls.length - 4 ].methodName, 'warn' );
208+ expect (
209+ jsAnyToDart (calls[calls.length - 4 ].methodArguments[0 ]),
210+ equals (
211+ 'Config certificatePinningConfiguration is not supported by the Web package. This config will be ignored.' ));
212+
213+ expect (calls[calls.length - 3 ].methodName, 'warn' );
214+ expect (
215+ jsAnyToDart (calls[calls.length - 3 ].methodArguments[0 ]),
216+ equals (
217+ 'Config encryptionEnabled is not supported by the Web package. This config will be ignored.' ));
218+
219+ expect (calls[calls.length - 2 ].methodName, 'warn' );
220+ expect (
221+ jsAnyToDart (calls[calls.length - 2 ].methodArguments[0 ]),
222+ equals (
223+ 'Config eventsPerPush is not supported by the Web package. This config will be ignored.' ));
224+
225+ expect (calls[calls.length - 1 ].methodName, 'warn' );
226+ expect (
227+ jsAnyToDart (calls[calls.length - 1 ].methodArguments[0 ]),
228+ equals (
229+ 'Config persistentAttributesEnabled is not supported by the Web package. This config will be ignored.' ));
200230 });
201231
202232 test ('init with config: SyncConfig.flagSets' , () async {
@@ -209,9 +239,9 @@ void main() {
209239 sdkConfiguration: SplitConfiguration (
210240 syncConfig: SyncConfig .flagSets (['flag_set_1' , 'flag_set_2' ])));
211241
212- expect (methodName, 'SplitFactory' );
242+ expect (calls.last. methodName, 'SplitFactory' );
213243 expect (
214- jsObjectToMap (methodArguments[0 ]),
244+ jsObjectToMap (calls.last. methodArguments[0 ]),
215245 equals ({
216246 'core' : {
217247 'authorizationKey' : 'api-key' ,
0 commit comments