Skip to content

Commit

Permalink
fixed tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Satyam Jha committed Jan 28, 2025
1 parent 5b5fbbf commit c1fdb91
Show file tree
Hide file tree
Showing 2 changed files with 200 additions and 172 deletions.
16 changes: 10 additions & 6 deletions test/helpers/test_helpers.dart
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,10 @@ import 'test_helpers.mocks.dart';
[],
customMocks: [
MockSpec<NavigationService>(onMissingStub: OnMissingStub.returnDefault),
MockSpec<GraphqlConfig>(onMissingStub: OnMissingStub.returnDefault),
MockSpec<GraphqlConfig>(
as: #MockGraphqlConfig,
onMissingStub: OnMissingStub.returnDefault,
),
MockSpec<GraphQLClient>(onMissingStub: OnMissingStub.returnDefault),
MockSpec<PostService>(onMissingStub: OnMissingStub.returnDefault),
MockSpec<MultiMediaPickerService>(
Expand Down Expand Up @@ -302,13 +305,14 @@ GraphqlConfig getAndRegisterGraphqlConfig() {
_removeRegistrationIfExists<GraphqlConfig>();
final service = MockGraphqlConfig();

when(service.httpLink).thenReturn(
HttpLink(
'https://talawa-graphql-api.herokuapp.com/graphql',
httpClient: MockHttpClient(),
),
final mockLink = HttpLink(
'https://talawa-graphql-api.herokuapp.com/graphql',
httpClient: MockHttpClient(),
);

// Use stub instead of when for better null safety handling
when(service.httpLink).thenReturn(mockLink);

when(service.clientToQuery()).thenAnswer((realInvocation) {
// return GraphQLClient(
// cache: GraphQLCache(partialDataPolicy: PartialDataCachePolicy.accept),
Expand Down
Loading

0 comments on commit c1fdb91

Please sign in to comment.