57 lines
1.6 KiB
Dart
57 lines
1.6 KiB
Dart
import 'package:flutter_test/flutter_test.dart';
|
|
import 'package:social_app/features/auth/data/models/signup_request.dart';
|
|
import 'package:social_app/features/auth/data/models/login_request.dart';
|
|
import 'package:social_app/features/auth/data/models/auth_response.dart';
|
|
|
|
void main() {
|
|
group('SignupStartRequest', () {
|
|
test('serializes to JSON', () {
|
|
final request = SignupStartRequest(
|
|
username: 'testuser',
|
|
email: 'test@example.com',
|
|
password: 'password123',
|
|
);
|
|
|
|
final json = request.toJson();
|
|
|
|
expect(json['username'], 'testuser');
|
|
expect(json['email'], 'test@example.com');
|
|
expect(json['password'], 'password123');
|
|
});
|
|
});
|
|
|
|
group('LoginRequest', () {
|
|
test('serializes to JSON', () {
|
|
final request = LoginRequest(
|
|
email: 'test@example.com',
|
|
password: 'password123',
|
|
);
|
|
|
|
final json = request.toJson();
|
|
|
|
expect(json['email'], 'test@example.com');
|
|
expect(json['password'], 'password123');
|
|
});
|
|
});
|
|
|
|
group('AuthResponse', () {
|
|
test('parses from JSON', () {
|
|
final json = {
|
|
'access_token': 'test_access',
|
|
'refresh_token': 'test_refresh',
|
|
'expires_in': 3600,
|
|
'token_type': 'bearer',
|
|
'user': {'id': '123', 'email': 'test@example.com'},
|
|
};
|
|
|
|
final response = AuthResponse.fromJson(json);
|
|
|
|
expect(response.accessToken, 'test_access');
|
|
expect(response.refreshToken, 'test_refresh');
|
|
expect(response.expiresIn, 3600);
|
|
expect(response.user.id, '123');
|
|
expect(response.user.email, 'test@example.com');
|
|
});
|
|
});
|
|
}
|