mirror of
https://github.com/foss42/apidash.git
synced 2025-12-03 03:17:00 +08:00
tests: add chat model tests(cv: 100)
This commit is contained in:
27
test/dashbot/models/chat_response_model_test.dart
Normal file
27
test/dashbot/models/chat_response_model_test.dart
Normal file
@@ -0,0 +1,27 @@
|
||||
import 'package:apidash/dashbot/core/constants/constants.dart';
|
||||
import 'package:apidash/dashbot/features/chat/models/chat_response.dart';
|
||||
import 'package:test/test.dart';
|
||||
|
||||
void main() {
|
||||
group('ChatResponse equality & copyWith', () {
|
||||
test('equality & hashCode', () {
|
||||
const r1 =
|
||||
ChatResponse(content: 'Hi', messageType: ChatMessageType.general);
|
||||
const r2 =
|
||||
ChatResponse(content: 'Hi', messageType: ChatMessageType.general);
|
||||
expect(r1, r2);
|
||||
expect(r1.hashCode, r2.hashCode);
|
||||
expect(r1.toString(), contains('ChatResponse'));
|
||||
});
|
||||
|
||||
test('copyWith modifies only provided fields', () {
|
||||
const r1 = ChatResponse(content: 'One');
|
||||
final r2 = r1.copyWith(content: 'Two');
|
||||
expect(r2.content, 'Two');
|
||||
expect(r2.messageType, isNull);
|
||||
final r3 = r2.copyWith(messageType: ChatMessageType.generateCode);
|
||||
expect(r3.messageType, ChatMessageType.generateCode);
|
||||
expect(r3.content, 'Two');
|
||||
});
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user