@@ -172,4 +172,79 @@ void main() {
172
172
expect (pkceHttpClient.lastRequestBody['auth_code' ], 'my-code-verifier' );
173
173
});
174
174
});
175
+ group ('EmptyLocalStorage' , () {
176
+ late EmptyLocalStorage localStorage;
177
+
178
+ setUp (() async {
179
+ mockAppLink ();
180
+
181
+ localStorage = const EmptyLocalStorage ();
182
+ // Initialize the Supabase singleton
183
+ await Supabase .initialize (
184
+ url: supabaseUrl,
185
+ anonKey: supabaseKey,
186
+ debug: false ,
187
+ authOptions: FlutterAuthClientOptions (
188
+ localStorage: localStorage,
189
+ pkceAsyncStorage: MockAsyncStorage (),
190
+ ),
191
+ );
192
+ });
193
+
194
+ test ('initialize does nothing' , () async {
195
+ // Should not throw any exceptions
196
+ await localStorage.initialize ();
197
+ });
198
+
199
+ test ('hasAccessToken returns false' , () async {
200
+ final result = await localStorage.hasAccessToken ();
201
+ expect (result, false );
202
+ });
203
+
204
+ test ('accessToken returns null' , () async {
205
+ final result = await localStorage.accessToken ();
206
+ expect (result, null );
207
+ });
208
+
209
+ test ('removePersistedSession does nothing' , () async {
210
+ // Should not throw any exceptions
211
+ await localStorage.removePersistedSession ();
212
+ });
213
+
214
+ test ('persistSession does nothing' , () async {
215
+ // Should not throw any exceptions
216
+ await localStorage.persistSession ('test-session-string' );
217
+ });
218
+
219
+ test ('all methods work together in a typical flow' , () async {
220
+ // Initialize the storage
221
+ await localStorage.initialize ();
222
+
223
+ // Check if there's a token (should be false)
224
+ final hasToken = await localStorage.hasAccessToken ();
225
+ expect (hasToken, false );
226
+
227
+ // Get the token (should be null)
228
+ final token = await localStorage.accessToken ();
229
+ expect (token, null );
230
+
231
+ // Try to persist a session
232
+ await localStorage.persistSession ('test-session-data' );
233
+
234
+ // Check if there's a token after persisting (should still be false)
235
+ final hasTokenAfterPersist = await localStorage.hasAccessToken ();
236
+ expect (hasTokenAfterPersist, false );
237
+
238
+ // Get the token after persisting (should still be null)
239
+ final tokenAfterPersist = await localStorage.accessToken ();
240
+ expect (tokenAfterPersist, null );
241
+
242
+ // Try to remove the session
243
+ await localStorage.removePersistedSession ();
244
+
245
+ // Check if there's a token after removing (should still be false)
246
+ final hasTokenAfterRemove = await localStorage.hasAccessToken ();
247
+ expect (hasTokenAfterRemove, false );
248
+ });
249
+ });
175
250
}
0 commit comments