Skip to content

Commit

Permalink
Unit test for event service with 100% coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
MohitMaulekhi committed Dec 23, 2024
1 parent fd19949 commit 0493c5b
Showing 1 changed file with 24 additions and 1 deletion.
25 changes: 24 additions & 1 deletion test/service_tests/event_service_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -417,7 +417,7 @@ void main() {
);
});

test('Test fetchVolunteerGroupsByEvent method', () async {
test('Test fetchVolunteerGroupsByEvent method success', () async {
final dataBaseMutationFunctions = locator<DataBaseMutationFunctions>();
const query = '';
const eventId = 'eventId123';
Expand Down Expand Up @@ -457,6 +457,29 @@ void main() {
expect(result[0].id, 'groupId1');
expect(result[1].id, 'groupId2');
});
test('Test fetchVolunteerGroupsByEvent method failure', () async {
final dataBaseMutationFunctions = locator<DataBaseMutationFunctions>();
const eventId = 'eventId123';
when(
dataBaseMutationFunctions.gqlAuthQuery(
EventQueries().fetchVolunteerGroups(),
variables: {
"where": {"eventId": eventId},
},
),
).thenThrow(
Exception("query error"),
);

final service = EventService();

try {
await service.fetchVolunteerGroupsByEvent(eventId);
} catch (e) {
expect(e, isA<Exception>());
expect(e.toString(), equals('Exception: query error'));
}
});
test('fetchAgendaCategories returns correct data', () async {
const orgId = 'org123';
final mockResult = QueryResult(
Expand Down

0 comments on commit 0493c5b

Please sign in to comment.