refactor(frontend): adapt to RESTful API routes

This commit is contained in:
qzl
2026-02-26 14:28:58 +08:00
parent 5b8b584013
commit d635d9a5e0
16 changed files with 210 additions and 115 deletions
@@ -65,12 +65,8 @@ void main() {
password: const Password.dirty('password123'),
),
setUp: () {
when(() => mockRepository.signupStart(any())).thenAnswer(
(_) async => SignupStartResponse(
status: 'ok',
email: 'test@example.com',
message: 'Code sent',
),
when(() => mockRepository.createVerification(any())).thenAnswer(
(_) async => VerificationCreateResponse(email: 'test@example.com'),
);
},
act: (c) => c.sendCodeSilently(),
@@ -85,7 +81,7 @@ void main() {
),
],
verify: (_) {
verify(() => mockRepository.signupStart(any())).called(1);
verify(() => mockRepository.createVerification(any())).called(1);
},
);
@@ -99,7 +95,7 @@ void main() {
),
setUp: () {
when(
() => mockRepository.signupStart(any()),
() => mockRepository.createVerification(any()),
).thenThrow(ServerException('Network error'));
},
act: (c) => c.sendCodeSilently(),
@@ -113,12 +109,12 @@ void main() {
),
],
verify: (_) {
verify(() => mockRepository.signupStart(any())).called(1);
verify(() => mockRepository.createVerification(any())).called(1);
},
);
blocTest<RegisterCubit, RegisterState>(
'does not call signupStart when input is invalid',
'does not call createVerification when input is invalid',
build: () => cubit,
seed: () => RegisterState(
username: const Username.dirty(''),
@@ -128,7 +124,7 @@ void main() {
act: (c) => c.sendCodeSilently(),
expect: () => [],
verify: (_) {
verifyNever(() => mockRepository.signupStart(any()));
verifyNever(() => mockRepository.createVerification(any()));
},
);
@@ -144,7 +140,7 @@ void main() {
act: (c) => c.sendCodeSilently(),
expect: () => [],
verify: (_) {
verifyNever(() => mockRepository.signupStart(any()));
verifyNever(() => mockRepository.createVerification(any()));
},
);
});
@@ -161,7 +157,7 @@ void main() {
.having((s) => s.errorMessage, 'errorMessage', '验证码发送失败,请返回上一步重试'),
],
verify: (_) {
verifyNever(() => mockRepository.signupResend(any()));
verifyNever(() => mockRepository.resendVerification(any()));
},
);
@@ -171,8 +167,8 @@ void main() {
seed: () => RegisterState(pendingEmail: 'test@example.com'),
setUp: () {
when(
() => mockRepository.signupResend(any()),
).thenAnswer((_) async => SignupResendResponse(message: 'Code sent'));
() => mockRepository.resendVerification(any()),
).thenAnswer((_) async {});
},
act: (c) => c.resendCode(),
expect: () => [
@@ -188,7 +184,7 @@ void main() {
),
],
verify: (_) {
verify(() => mockRepository.signupResend(any())).called(1);
verify(() => mockRepository.resendVerification(any())).called(1);
},
);
@@ -198,7 +194,7 @@ void main() {
seed: () => RegisterState(pendingEmail: 'test@example.com'),
setUp: () {
when(
() => mockRepository.signupResend(any()),
() => mockRepository.resendVerification(any()),
).thenThrow(ServerException('Network error'));
},
act: (c) => c.resendCode(),