Skip to content

Commit 949ef0d

Browse files
committed
formatted document
1 parent 092cddf commit 949ef0d

File tree

2 files changed

+50
-41
lines changed

2 files changed

+50
-41
lines changed

packages/supabase_flutter/test/lifecycle_test.dart

Lines changed: 35 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -25,56 +25,62 @@ void main() {
2525
}
2626
});
2727

28-
test('onResumed handles realtime reconnection when channels exist', () async {
28+
test('onResumed handles realtime reconnection when channels exist',
29+
() async {
2930
await Supabase.initialize(
3031
url: supabaseUrl,
3132
anonKey: supabaseKey,
3233
);
3334

3435
final supabase = Supabase.instance;
35-
36+
3637
// Create a mock channel to simulate having active channels
3738
final channel = supabase.client.realtime.channel('test-channel');
38-
39+
3940
// Simulate app lifecycle state changes
4041
supabase.didChangeAppLifecycleState(AppLifecycleState.paused);
41-
42+
4243
// Verify realtime was disconnected
4344
expect(supabase.client.realtime.connState, isNot(SocketStates.open));
44-
45+
4546
// Simulate app resuming
4647
supabase.didChangeAppLifecycleState(AppLifecycleState.resumed);
47-
48+
4849
// The onResumed method should be called
4950
expect(supabase.client.realtime, isNotNull);
50-
51+
5152
// Clean up
5253
await channel.unsubscribe();
5354
});
5455

55-
test('didChangeAppLifecycleState handles different lifecycle states', () async {
56+
test('didChangeAppLifecycleState handles different lifecycle states',
57+
() async {
5658
await Supabase.initialize(
5759
url: supabaseUrl,
5860
anonKey: supabaseKey,
5961
);
6062

6163
final supabase = Supabase.instance;
62-
64+
6365
// Test paused state
64-
expect(() => supabase.didChangeAppLifecycleState(AppLifecycleState.paused),
65-
returnsNormally);
66-
66+
expect(
67+
() => supabase.didChangeAppLifecycleState(AppLifecycleState.paused),
68+
returnsNormally);
69+
6770
// Test detached state
68-
expect(() => supabase.didChangeAppLifecycleState(AppLifecycleState.detached),
69-
returnsNormally);
70-
71+
expect(
72+
() => supabase.didChangeAppLifecycleState(AppLifecycleState.detached),
73+
returnsNormally);
74+
7175
// Test resumed state
72-
expect(() => supabase.didChangeAppLifecycleState(AppLifecycleState.resumed),
73-
returnsNormally);
74-
76+
expect(
77+
() => supabase.didChangeAppLifecycleState(AppLifecycleState.resumed),
78+
returnsNormally);
79+
7580
// Test inactive state (should be handled by default case)
76-
expect(() => supabase.didChangeAppLifecycleState(AppLifecycleState.inactive),
77-
returnsNormally);
81+
expect(
82+
() => supabase.didChangeAppLifecycleState(AppLifecycleState.inactive),
83+
returnsNormally);
7884
});
7985

8086
test('onResumed handles disconnecting state properly', () async {
@@ -84,18 +90,18 @@ void main() {
8490
);
8591

8692
final supabase = Supabase.instance;
87-
93+
8894
// Create a channel to ensure channels exist
8995
final channel = supabase.client.realtime.channel('test-channel');
90-
96+
9197
// Simulate disconnecting state by pausing first
9298
supabase.didChangeAppLifecycleState(AppLifecycleState.paused);
93-
99+
94100
// Now test resuming while in disconnecting state
95101
await supabase.onResumed();
96-
102+
97103
expect(supabase.client.realtime, isNotNull);
98-
104+
99105
// Clean up
100106
await channel.unsubscribe();
101107
});
@@ -107,15 +113,15 @@ void main() {
107113
);
108114

109115
final supabase = Supabase.instance;
110-
116+
111117
// The observer should be added during initialization
112118
expect(supabase, isNotNull);
113-
119+
114120
// Dispose should remove the observer
115121
await supabase.dispose();
116-
122+
117123
// After disposal, the instance should be reset
118124
expect(() => Supabase.instance, throwsA(isA<AssertionError>()));
119125
});
120126
});
121-
}
127+
}

packages/supabase_flutter/test/storage_test.dart

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -128,17 +128,18 @@ void main() {
128128
test('setItem overwrites existing value', () async {
129129
const initialValue = 'initial';
130130
const newValue = 'new';
131-
131+
132132
await asyncStorage.setItem(key: testKey, value: initialValue);
133133
expect(await asyncStorage.getItem(key: testKey), initialValue);
134-
134+
135135
await asyncStorage.setItem(key: testKey, value: newValue);
136136
expect(await asyncStorage.getItem(key: testKey), newValue);
137137
});
138138

139139
test('removeItem handles non-existent key gracefully', () async {
140140
// Should not throw when removing a key that doesn't exist
141-
expect(() => asyncStorage.removeItem(key: 'non_existent_key'), returnsNormally);
141+
expect(() => asyncStorage.removeItem(key: 'non_existent_key'),
142+
returnsNormally);
142143
await asyncStorage.removeItem(key: 'non_existent_key');
143144
});
144145
});
@@ -164,16 +165,17 @@ void main() {
164165
test('persistSession does nothing and returns normally', () async {
165166
expect(() => emptyStorage.persistSession('test'), returnsNormally);
166167
await emptyStorage.persistSession('test');
167-
168+
168169
// Should still return null/false after persist attempt
169170
expect(await emptyStorage.hasAccessToken(), false);
170171
expect(await emptyStorage.accessToken(), null);
171172
});
172173

173-
test('removePersistedSession does nothing and returns normally', () async {
174+
test('removePersistedSession does nothing and returns normally',
175+
() async {
174176
expect(() => emptyStorage.removePersistedSession(), returnsNormally);
175177
await emptyStorage.removePersistedSession();
176-
178+
177179
// Should still return null/false after remove attempt
178180
expect(await emptyStorage.hasAccessToken(), false);
179181
expect(await emptyStorage.accessToken(), null);
@@ -187,7 +189,7 @@ void main() {
187189
persistSessionKey: 'test_empty_session',
188190
);
189191
await localStorage.initialize();
190-
192+
191193
await localStorage.persistSession('');
192194
expect(await localStorage.hasAccessToken(), true);
193195
expect(await localStorage.accessToken(), '');
@@ -198,8 +200,9 @@ void main() {
198200
persistSessionKey: 'test_special_chars',
199201
);
200202
await localStorage.initialize();
201-
202-
const specialSession = '{"access_token": "áéíóú-test-token-!@#\$%^&*()"}';
203+
204+
const specialSession =
205+
'{"access_token": "áéíóú-test-token-!@#\$%^&*()"}';
203206
await localStorage.persistSession(specialSession);
204207
expect(await localStorage.hasAccessToken(), true);
205208
expect(await localStorage.accessToken(), specialSession);
@@ -210,16 +213,16 @@ void main() {
210213
persistSessionKey: 'test_multiple_ops',
211214
);
212215
await localStorage.initialize();
213-
216+
214217
// Multiple persist operations
215218
await localStorage.persistSession('session1');
216219
await localStorage.persistSession('session2');
217220
expect(await localStorage.accessToken(), 'session2');
218-
221+
219222
// Remove then add again
220223
await localStorage.removePersistedSession();
221224
expect(await localStorage.hasAccessToken(), false);
222-
225+
223226
await localStorage.persistSession('session3');
224227
expect(await localStorage.accessToken(), 'session3');
225228
});

0 commit comments

Comments
 (0)