Skip to content

Commit 89accf0

Browse files
committed
style(remote_config): format the new tests for the Dart 3.10 formatter
1 parent f475a0c commit 89accf0

2 files changed

Lines changed: 85 additions & 76 deletions

File tree

‎packages/firebase_remote_config/firebase_remote_config_platform_interface/test/method_channel/method_channel_firebase_remote_config_test.dart‎

Lines changed: 45 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,9 @@ void main() {
2323
});
2424

2525
group('onConfigUpdated', () {
26-
const EventChannel channel =
27-
EventChannel('plugins.flutter.io/firebase_remote_config_updated');
26+
const EventChannel channel = EventChannel(
27+
'plugins.flutter.io/firebase_remote_config_updated',
28+
);
2829

2930
late FirebaseApp app;
3031

@@ -42,12 +43,13 @@ void main() {
4243
void mockNativeEvents(void Function(MockStreamHandlerEventSink) send) {
4344
TestDefaultBinaryMessengerBinding.instance.defaultBinaryMessenger
4445
.setMockStreamHandler(
45-
channel,
46-
MockStreamHandler.inline(
47-
onListen: (Object? arguments, MockStreamHandlerEventSink events) =>
48-
send(events),
49-
),
50-
);
46+
channel,
47+
MockStreamHandler.inline(
48+
onListen:
49+
(Object? arguments, MockStreamHandlerEventSink events) =>
50+
send(events),
51+
),
52+
);
5153
}
5254

5355
Matcher isRealtimeError(String code, String message) {
@@ -57,45 +59,49 @@ void main() {
5759
.having((e) => e.message, 'message', message);
5860
}
5961

60-
test('reports realtime errors as FirebaseExceptions with their code',
61-
() async {
62-
const List<String> codes = <String>[
63-
'config-update-stream-error',
64-
'config-update-message-invalid',
65-
'config-update-not-fetched',
66-
'config-update-unavailable',
67-
'unknown',
68-
];
69-
mockNativeEvents((events) {
70-
for (final String code in codes) {
71-
events.error(
72-
code: 'firebase_remote_config',
73-
message: 'native message',
74-
details: <String, String>{'code': code, 'message': 'msg $code'},
75-
);
76-
}
77-
});
78-
79-
final remoteConfig = MethodChannelFirebaseRemoteConfig(app: app);
80-
81-
await expectLater(
82-
remoteConfig.onConfigUpdated,
83-
emitsInOrder(<Matcher>[
84-
for (final String code in codes)
85-
emitsError(isRealtimeError(code, 'msg $code')),
86-
]),
87-
);
88-
});
62+
test(
63+
'reports realtime errors as FirebaseExceptions with their code',
64+
() async {
65+
const List<String> codes = <String>[
66+
'config-update-stream-error',
67+
'config-update-message-invalid',
68+
'config-update-not-fetched',
69+
'config-update-unavailable',
70+
'unknown',
71+
];
72+
mockNativeEvents((events) {
73+
for (final String code in codes) {
74+
events.error(
75+
code: 'firebase_remote_config',
76+
message: 'native message',
77+
details: <String, String>{'code': code, 'message': 'msg $code'},
78+
);
79+
}
80+
});
81+
82+
final remoteConfig = MethodChannelFirebaseRemoteConfig(app: app);
83+
84+
await expectLater(
85+
remoteConfig.onConfigUpdated,
86+
emitsInOrder(<Matcher>[
87+
for (final String code in codes)
88+
emitsError(isRealtimeError(code, 'msg $code')),
89+
]),
90+
);
91+
},
92+
);
8993

9094
test('keeps the stream open after a realtime error', () async {
9195
mockNativeEvents((events) {
9296
events.error(
9397
code: 'firebase_remote_config',
94-
message: 'Unable to connect to the server. Try again in a few '
98+
message:
99+
'Unable to connect to the server. Try again in a few '
95100
'minutes. HTTP status code: 503',
96101
details: <String, String>{
97102
'code': 'config-update-stream-error',
98-
'message': 'Unable to connect to the server. Try again in a few '
103+
'message':
104+
'Unable to connect to the server. Try again in a few '
99105
'minutes. HTTP status code: 503',
100106
},
101107
);

‎packages/firebase_remote_config/firebase_remote_config_web/test/internals_test.dart‎

Lines changed: 40 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -23,45 +23,48 @@ JSObject firebaseError(String code, String message) {
2323

2424
void main() {
2525
group('convertWebExceptions', () {
26-
test('reports realtime errors with the codes Android and iOS use',
27-
() async {
28-
const Map<String, String> codes = <String, String>{
29-
'remoteconfig/stream-error': 'config-update-stream-error',
30-
'remoteconfig/update-message-invalid': 'config-update-message-invalid',
31-
'remoteconfig/update-not-fetched': 'config-update-not-fetched',
32-
'remoteconfig/realtime-unavailable': 'config-update-unavailable',
33-
};
34-
final controller = StreamController<String>.broadcast(sync: true);
35-
final stream = convertWebExceptions(() => controller.stream);
26+
test(
27+
'reports realtime errors with the codes Android and iOS use',
28+
() async {
29+
const Map<String, String> codes = <String, String>{
30+
'remoteconfig/stream-error': 'config-update-stream-error',
31+
'remoteconfig/update-message-invalid':
32+
'config-update-message-invalid',
33+
'remoteconfig/update-not-fetched': 'config-update-not-fetched',
34+
'remoteconfig/realtime-unavailable': 'config-update-unavailable',
35+
};
36+
final controller = StreamController<String>.broadcast(sync: true);
37+
final stream = convertWebExceptions(() => controller.stream);
3638

37-
final expectation = expectLater(
38-
stream,
39-
emitsInOrder(<Object>[
40-
for (final MapEntry(key: jsCode, value: code) in codes.entries)
41-
emitsError(
42-
isA<FirebaseException>()
43-
.having((e) => e.plugin, 'plugin', 'firebase_remote_config')
44-
.having((e) => e.code, 'code', code)
45-
.having(
46-
(e) => e.message,
47-
'message',
48-
allOf(
49-
contains('Unable to connect'),
50-
isNot(contains(jsCode)),
39+
final expectation = expectLater(
40+
stream,
41+
emitsInOrder(<Object>[
42+
for (final MapEntry(key: jsCode, value: code) in codes.entries)
43+
emitsError(
44+
isA<FirebaseException>()
45+
.having((e) => e.plugin, 'plugin', 'firebase_remote_config')
46+
.having((e) => e.code, 'code', code)
47+
.having(
48+
(e) => e.message,
49+
'message',
50+
allOf(
51+
contains('Unable to connect'),
52+
isNot(contains(jsCode)),
53+
),
5154
),
52-
),
53-
),
54-
// The stream stays open after an error.
55-
'update',
56-
]),
57-
);
58-
for (final String jsCode in codes.keys) {
59-
controller.addError(firebaseError(jsCode, 'Unable to connect'));
60-
}
61-
controller.add('update');
55+
),
56+
// The stream stays open after an error.
57+
'update',
58+
]),
59+
);
60+
for (final String jsCode in codes.keys) {
61+
controller.addError(firebaseError(jsCode, 'Unable to connect'));
62+
}
63+
controller.add('update');
6264

63-
await expectation;
64-
await controller.close();
65-
});
65+
await expectation;
66+
await controller.close();
67+
},
68+
);
6669
});
6770
}

0 commit comments

Comments
 (0)