feat: 결재·마스터 실연동 업데이트
This commit is contained in:
@@ -0,0 +1,65 @@
|
||||
import 'package:dio/dio.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:mocktail/mocktail.dart';
|
||||
|
||||
import 'package:superport_v2/core/network/api_client.dart';
|
||||
import 'package:superport_v2/features/masters/user/data/repositories/user_repository_remote.dart';
|
||||
|
||||
class _MockApiClient extends Mock implements ApiClient {}
|
||||
|
||||
void main() {
|
||||
late ApiClient apiClient;
|
||||
late UserRepositoryRemote repository;
|
||||
|
||||
setUpAll(() {
|
||||
registerFallbackValue(Options());
|
||||
registerFallbackValue(CancelToken());
|
||||
});
|
||||
|
||||
setUp(() {
|
||||
apiClient = _MockApiClient();
|
||||
repository = UserRepositoryRemote(apiClient: apiClient);
|
||||
});
|
||||
|
||||
test('목록 조회 시 include=group 파라미터를 전달한다', () async {
|
||||
when(
|
||||
() => apiClient.get<Map<String, dynamic>>(
|
||||
any(),
|
||||
query: any(named: 'query'),
|
||||
options: any(named: 'options'),
|
||||
cancelToken: any(named: 'cancelToken'),
|
||||
),
|
||||
).thenAnswer(
|
||||
(_) async => Response<Map<String, dynamic>>(
|
||||
data: {
|
||||
'items': [
|
||||
{
|
||||
'id': 1,
|
||||
'employee_no': 'E-001',
|
||||
'employee_name': '홍길동',
|
||||
'group': {'id': 2, 'group_name': '관리자'},
|
||||
},
|
||||
],
|
||||
},
|
||||
requestOptions: RequestOptions(path: '/api/v1/employees'),
|
||||
statusCode: 200,
|
||||
),
|
||||
);
|
||||
|
||||
await repository.list();
|
||||
|
||||
final captured = verify(
|
||||
() => apiClient.get<Map<String, dynamic>>(
|
||||
captureAny(),
|
||||
query: captureAny(named: 'query'),
|
||||
options: any(named: 'options'),
|
||||
cancelToken: any(named: 'cancelToken'),
|
||||
),
|
||||
).captured;
|
||||
final path = captured[0] as String;
|
||||
final query = captured[1] as Map<String, dynamic>;
|
||||
|
||||
expect(path, equals('/api/v1/employees'));
|
||||
expect(query['include'], 'group');
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user