Files
Auto-GPT/test/task_request_body_test.dart
hunteraraujo 8950ab44be Implement and Test TaskRequestBody Model
This commit adds the TaskRequestBody class, which is designed to encapsulate the request body when creating a new task. The class includes a toJson method for easy serialization to JSON format.

Additionally, unit tests have been written to ensure that the TaskRequestBody object is created with the correct values and that it serializes to the expected JSON structure.

- Added TaskRequestBody class with input and optional additionalInput fields.
- Implemented toJson method for converting an instance of the class to JSON.
- Added unit tests to verify both object creation and JSON serialization.

These changes provide a standardized way to manage the request body when creating new tasks, improving the overall code quality and maintainability.
2023-08-31 14:39:03 -07:00

27 lines
831 B
Dart

import 'package:auto_gpt_flutter_client/models/task_request_body.dart';
import 'package:flutter_test/flutter_test.dart';
void main() {
group('TaskRequestBody', () {
test('should create TaskRequestBody with correct values', () {
final taskRequestBody = TaskRequestBody(
input: 'Do something', additionalInput: {'key': 'value'});
expect(taskRequestBody.input, 'Do something');
expect(taskRequestBody.additionalInput, {'key': 'value'});
});
test('should convert TaskRequestBody to correct JSON', () {
final taskRequestBody = TaskRequestBody(
input: 'Do something', additionalInput: {'key': 'value'});
final json = taskRequestBody.toJson();
expect(json, {
'input': 'Do something',
'additional_input': {'key': 'value'}
});
});
});
}