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:
49
test/dashbot/models/constants_model_test.dart
Normal file
49
test/dashbot/models/constants_model_test.dart
Normal file
@@ -0,0 +1,49 @@
|
||||
import 'package:apidash/dashbot/core/constants/constants.dart';
|
||||
import 'package:test/test.dart';
|
||||
|
||||
void main() {
|
||||
group('Constants enum mappings', () {
|
||||
test('ChatActionType round-trip mapping', () {
|
||||
final map = <ChatActionType, String>{
|
||||
ChatActionType.updateField: 'update_field',
|
||||
ChatActionType.addHeader: 'add_header',
|
||||
ChatActionType.updateHeader: 'update_header',
|
||||
ChatActionType.deleteHeader: 'delete_header',
|
||||
ChatActionType.updateBody: 'update_body',
|
||||
ChatActionType.updateUrl: 'update_url',
|
||||
ChatActionType.updateMethod: 'update_method',
|
||||
ChatActionType.showLanguages: 'show_languages',
|
||||
ChatActionType.applyCurl: 'apply_curl',
|
||||
ChatActionType.applyOpenApi: 'apply_openapi',
|
||||
ChatActionType.downloadDoc: 'download_doc',
|
||||
ChatActionType.other: 'other',
|
||||
ChatActionType.noAction: 'no_action',
|
||||
ChatActionType.uploadAsset: 'upload_asset',
|
||||
};
|
||||
map.forEach((enumVal, strVal) {
|
||||
expect(chatActionTypeToString(enumVal), strVal);
|
||||
expect(chatActionTypeFromString(strVal), enumVal);
|
||||
});
|
||||
// unknown
|
||||
expect(chatActionTypeFromString('some_new_type'), ChatActionType.other);
|
||||
});
|
||||
|
||||
test('ChatActionTarget round-trip mapping', () {
|
||||
final map = <ChatActionTarget, String>{
|
||||
ChatActionTarget.httpRequestModel: 'httpRequestModel',
|
||||
ChatActionTarget.codegen: 'codegen',
|
||||
ChatActionTarget.test: 'test',
|
||||
ChatActionTarget.code: 'code',
|
||||
ChatActionTarget.attachment: 'attachment',
|
||||
ChatActionTarget.documentation: 'documentation',
|
||||
};
|
||||
map.forEach((enumVal, strVal) {
|
||||
expect(chatActionTargetToString(enumVal), strVal);
|
||||
expect(chatActionTargetFromString(strVal), enumVal);
|
||||
});
|
||||
// unknown maps to default httpRequestModel
|
||||
expect(chatActionTargetFromString('weird'),
|
||||
ChatActionTarget.httpRequestModel);
|
||||
});
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user