Skip to content

Commit aa8866d

Browse files
Add InLocalStorage mock and update test expectations
1 parent 3f29ce3 commit aa8866d

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

splitio_web/test/splitio_web_test.dart

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -856,7 +856,12 @@ void main() {
856856
clearOnInit: true,
857857
)));
858858

859-
expect(mock.calls[mock.calls.length - 2].methodName, 'InfoLogger');
859+
expect(mock.calls[mock.calls.length - 3].methodName, 'InfoLogger');
860+
expect(mock.calls[mock.calls.length - 2].methodName, 'InLocalStorage');
861+
expect(
862+
mock.calls[mock.calls.length - 2].methodArguments.map(jsAnyToDart), [
863+
{'type': 'LOCALSTORAGE', 'expirationDays': 100, 'clearOnInit': true}
864+
]);
860865

861866
expect(mock.calls.last.methodName, 'SplitFactory');
862867
expect(
@@ -876,7 +881,7 @@ void main() {
876881
'urls': {},
877882
'sync': {},
878883
'debug': {},
879-
'storage': {'type': 'LOCALSTORAGE', 'expirationDays': 100, 'clearOnInit': true }
884+
'storage': {}
880885
}));
881886

882887
mock.removeFactoryModules();

splitio_web/test/utils/js_interop_test_utils.dart

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -427,12 +427,21 @@ class SplitioMock {
427427
calls.add((methodName: 'ErrorLogger', methodArguments: []));
428428
return JSObject();
429429
}.toJS);
430+
reflectSet(
431+
splitio,
432+
'InLocalStorage'.toJS,
433+
(JS_ConfigurationStorage storageConfig) {
434+
calls.add(
435+
(methodName: 'InLocalStorage', methodArguments: [storageConfig]));
436+
return JSObject();
437+
}.toJS);
430438
}
431439

432440
void removeFactoryModules() {
433441
reflectSet(splitio, 'DebugLogger'.toJS, null);
434442
reflectSet(splitio, 'InfoLogger'.toJS, null);
435443
reflectSet(splitio, 'WarnLogger'.toJS, null);
436444
reflectSet(splitio, 'ErrorLogger'.toJS, null);
445+
reflectSet(splitio, 'InLocalStorage'.toJS, null);
437446
}
438447
}

0 commit comments

Comments
 (0)