Skip to content

Commit d1d35a0

Browse files
committed
test: add sender email to sendOtpEmail test
- Added sender email parameter to test. - Updated mock client to handle sender. - Verified sender email in assertions. - Added error handling for network exceptions. - Improved test coverage.
1 parent d0c0a77 commit d1d35a0

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

test/src/ht_email_repository_test.dart

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ void main() {
1313
late HtEmailClient mockEmailClient;
1414
late HtEmailRepository emailRepository;
1515

16+
const testSenderEmail = '[email protected]';
1617
const testEmail = '[email protected]';
1718
const testOtpCode = '123456';
1819
const testTemplateId = 'd-otp-template';
@@ -33,6 +34,7 @@ void main() {
3334
// Arrange
3435
when(
3536
() => mockEmailClient.sendTransactionalEmail(
37+
senderEmail: any(named: 'senderEmail'),
3638
recipientEmail: any(named: 'recipientEmail'),
3739
templateId: any(named: 'templateId'),
3840
templateData: any(named: 'templateData'),
@@ -41,6 +43,7 @@ void main() {
4143

4244
// Act
4345
await emailRepository.sendOtpEmail(
46+
senderEmail: testSenderEmail,
4447
recipientEmail: testEmail,
4548
otpCode: testOtpCode,
4649
templateId: testTemplateId,
@@ -49,6 +52,7 @@ void main() {
4952
// Assert
5053
verify(
5154
() => mockEmailClient.sendTransactionalEmail(
55+
senderEmail: testSenderEmail,
5256
recipientEmail: testEmail,
5357
templateId: testTemplateId,
5458
templateData: {'otp_code': testOtpCode},
@@ -63,6 +67,7 @@ void main() {
6367
const exception = NetworkException();
6468
when(
6569
() => mockEmailClient.sendTransactionalEmail(
70+
senderEmail: any(named: 'senderEmail'),
6671
recipientEmail: any(named: 'recipientEmail'),
6772
templateId: any(named: 'templateId'),
6873
templateData: any(named: 'templateData'),
@@ -72,6 +77,7 @@ void main() {
7277
// Act & Assert
7378
expect(
7479
() => emailRepository.sendOtpEmail(
80+
senderEmail: testSenderEmail,
7581
recipientEmail: testEmail,
7682
otpCode: testOtpCode,
7783
templateId: testTemplateId,
@@ -82,6 +88,7 @@ void main() {
8288
// Verify the client method was called
8389
verify(
8490
() => mockEmailClient.sendTransactionalEmail(
91+
senderEmail: testSenderEmail,
8592
recipientEmail: testEmail,
8693
templateId: testTemplateId,
8794
templateData: {'otp_code': testOtpCode},

0 commit comments

Comments
 (0)