Files
pipelines/app/test/features/chat/domain/chat_automations_test.dart
T

43 lines
1.5 KiB
Dart

import 'package:flutter_test/flutter_test.dart';
import 'package:pipelines_app/features/chat/domain/chat_automations.dart';
void main() {
test(
'only supported integer counts from the selected chat are displayed',
() {
ChatAutomationStatus read(Map<String, dynamic> fields) =>
ChatAutomationStatus.fromReply({
'chat_automations': {'session_id': 'chat', ...fields},
}, expectedSessionId: 'chat');
expect(read({'status': 'supported', 'active_count': 0}).count, 0);
expect(read({'status': 'supported', 'active_count': 2}).count, 2);
for (final fields in <Map<String, dynamic>>[
{'status': 'unavailable', 'active_count': 2},
{'status': 'unknown', 'active_count': 2},
{'status': 'supported', 'active_count': 1.5},
{'status': 'supported', 'active_count': -1},
{'status': 'supported'},
{'session_id': 'foreign', 'status': 'supported', 'active_count': 2},
]) {
expect(read(fields).count, isNull, reason: '$fields');
}
},
);
test('invalid report times remain unknown without losing a valid count', () {
for (final stamp in [null, 'yesterday', -1, 1.5, 9223372036854775807]) {
final result = ChatAutomationStatus.fromReply({
'chat_automations': {
'session_id': 'chat',
'status': 'supported',
'active_count': 1,
'observed_at_ms': stamp,
},
}, expectedSessionId: 'chat');
expect(result.count, 1);
expect(result.observedAt, isNull);
}
});
}