test(client): 用例名统一为 should_<期望>_when_<条件>(155/155)
为什么:红线第 8 条门禁立即生效,要求 Flutter 测试命名合规;此前 155 条用例名是英文自然语言 或中文描述,合规数 0/155,属存量欠账,按"先补齐再上新功能"在本批处理。 - 25 个测试文件、155 条用例改名,按「文件 + 旧名」精确定位,每条断言命中恰好 1 次才替换 - 只改名字字面量:改动行 155 删 + 155 增,无一行不含字符串字面量(断言与用例体零改动) - 门禁:dart analyze lib test = No issues found;flutter test = 155 全过
This commit is contained in:
1 parent
1853e1845c
commit
0e5d550b50
25 files changed
+155
-155
No files matched your search
@@ -28,7 +28,7 @@ void main() {
|
||||
});
|
||||
|
||||
group('platform support', () {
|
||||
test('android is the only supported target', () {
|
||||
test('should_support_only_android_when_target_is_checked', () {
|
||||
debugDefaultTargetPlatformOverride = TargetPlatform.android;
|
||||
expect(pip().isPlatformSupported, isTrue);
|
||||
|
||||
@@ -50,7 +50,7 @@ void main() {
|
||||
});
|
||||
|
||||
group('enter', () {
|
||||
test('is refused without touching the channel off android', () async {
|
||||
test('should_refuse_without_touching_channel_when_target_is_not_android', () async {
|
||||
debugDefaultTargetPlatformOverride = TargetPlatform.iOS;
|
||||
final calls = <MethodCall>[];
|
||||
messenger.setMockMethodCallHandler(channel, (call) async {
|
||||
@@ -63,7 +63,7 @@ void main() {
|
||||
expect(calls, isEmpty);
|
||||
});
|
||||
|
||||
test('a missing native answer counts as a refusal', () async {
|
||||
test('should_count_as_refused_when_native_answer_is_missing', () async {
|
||||
debugDefaultTargetPlatformOverride = TargetPlatform.android;
|
||||
messenger.setMockMethodCallHandler(channel, (call) async => null);
|
||||
addTearDown(() => messenger.setMockMethodCallHandler(channel, null));
|
||||
@@ -71,7 +71,7 @@ void main() {
|
||||
expect(await pip().enter(), isFalse);
|
||||
});
|
||||
|
||||
test('a native success is reported as entered', () async {
|
||||
test('should_report_entered_when_native_call_succeeds', () async {
|
||||
debugDefaultTargetPlatformOverride = TargetPlatform.android;
|
||||
final calls = <MethodCall>[];
|
||||
messenger.setMockMethodCallHandler(channel, (call) async {
|
||||
@@ -87,7 +87,7 @@ void main() {
|
||||
});
|
||||
|
||||
group('state listener', () {
|
||||
test('pip state changes reach the listener in order', () async {
|
||||
test('should_deliver_pip_state_changes_in_order_when_native_events_arrive', () async {
|
||||
final received = <bool>[];
|
||||
pip().setStateListener(received.add);
|
||||
|
||||
@@ -97,7 +97,7 @@ void main() {
|
||||
expect(received, [true, false]);
|
||||
});
|
||||
|
||||
test('only a literal true is read as enabled', () async {
|
||||
test('should_treat_only_literal_true_as_enabled_when_native_value_arrives', () async {
|
||||
final received = <bool>[];
|
||||
pip().setStateListener(received.add);
|
||||
|
||||
@@ -108,7 +108,7 @@ void main() {
|
||||
expect(received, [false, false, false]);
|
||||
});
|
||||
|
||||
test('unrelated native methods are ignored', () async {
|
||||
test('should_ignore_unrelated_native_methods_when_events_arrive', () async {
|
||||
final received = <bool>[];
|
||||
pip().setStateListener(received.add);
|
||||
|
||||
@@ -118,7 +118,7 @@ void main() {
|
||||
expect(received, [true]);
|
||||
});
|
||||
|
||||
test('clearing the listener silences later callbacks', () async {
|
||||
test('should_silence_later_callbacks_when_listener_is_cleared', () async {
|
||||
final received = <bool>[];
|
||||
final observer = pip()..setStateListener(received.add);
|
||||
await sendToDart('onPipChanged', true);
|
||||
|
||||
@@ -14,7 +14,7 @@ void main() {
|
||||
return jsonEncode({'code': code, 'message': message, 'data': data});
|
||||
}
|
||||
|
||||
test('should return the data field when the envelope code is zero', () async {
|
||||
test('should_return_data_field_when_envelope_code_is_zero', () async {
|
||||
final adapter = FakeHttpAdapter(
|
||||
(_) async => FakeHttpResponse(envelope({'id': 7})),
|
||||
);
|
||||
@@ -24,7 +24,7 @@ void main() {
|
||||
expect((data as Map)['id'], 7);
|
||||
});
|
||||
|
||||
test('should throw an ApiException carrying the server message when the envelope code is not zero', () async {
|
||||
test('should_throw_api_exception_with_server_message_when_envelope_code_is_not_zero', () async {
|
||||
final adapter = FakeHttpAdapter(
|
||||
(_) async => FakeHttpResponse(
|
||||
envelope(null, code: 40001, message: '邮箱格式不正确'),
|
||||
@@ -42,7 +42,7 @@ void main() {
|
||||
);
|
||||
});
|
||||
|
||||
test('should map a body without envelope to an ApiException carrying the http status', () async {
|
||||
test('should_map_to_api_exception_with_http_status_when_body_has_no_envelope', () async {
|
||||
final adapter = FakeHttpAdapter((_) async => FakeHttpResponse('oops', 502));
|
||||
final client = ApiClient(baseUrl: 'http://127.0.0.1:8081', adapter: adapter);
|
||||
|
||||
@@ -54,7 +54,7 @@ void main() {
|
||||
);
|
||||
});
|
||||
|
||||
test('should send the bearer token and the device header when both are available', () async {
|
||||
test('should_send_bearer_token_and_device_header_when_both_are_available', () async {
|
||||
final adapter = FakeHttpAdapter((_) async => FakeHttpResponse(envelope(null)));
|
||||
final client = ApiClient(
|
||||
baseUrl: 'http://127.0.0.1:8081',
|
||||
@@ -71,7 +71,7 @@ void main() {
|
||||
expect(request.headers['Accept'], 'application/json');
|
||||
});
|
||||
|
||||
test('should put the query map into the request uri', () async {
|
||||
test('should_put_query_map_into_request_uri_when_query_is_given', () async {
|
||||
final adapter = FakeHttpAdapter((_) async => FakeHttpResponse(envelope(null)));
|
||||
final client = ApiClient(baseUrl: 'http://127.0.0.1:8081', adapter: adapter);
|
||||
|
||||
@@ -83,7 +83,7 @@ void main() {
|
||||
expect(uri.queryParameters['page'], '2');
|
||||
});
|
||||
|
||||
test('should not refresh the token when the call opts out of auth retry', () async {
|
||||
test('should_skip_refresh_when_call_opts_out_of_auth_retry', () async {
|
||||
var refreshed = false;
|
||||
final adapter = FakeHttpAdapter(
|
||||
(_) async => FakeHttpResponse(envelope(null, code: 401, message: '登录已过期')),
|
||||
|
||||
Reference in new issue
Block a user