Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@ class StreamFeedsClientImpl implements StreamFeedsClient {
NetworkStateProvider? networkStateProvider,
AppLifecycleStateProvider? appLifecycleStateProvider,
List<AutomaticReconnectionPolicy>? reconnectionPolicies,
WebSocketProvider? wsProvider,
api.DefaultApi? feedsRestApi,
}) {
// TODO: Make this configurable
const endpointConfig = EndpointConfig.production;
Expand Down Expand Up @@ -105,6 +107,7 @@ class StreamFeedsClientImpl implements StreamFeedsClient {
event_resolvers.pollAnswerCastedFeedEventResolver,
event_resolvers.pollAnswerRemovedFeedEventResolver,
],
wsProvider: wsProvider,
);

_connectionRecoveryHandler = ConnectionRecoveryHandler(
Expand Down Expand Up @@ -152,7 +155,7 @@ class StreamFeedsClientImpl implements StreamFeedsClient {
_cdnClient = config.cdnClient ?? FeedsCdnClient(CdnApi(httpClient));
attachmentUploader = StreamAttachmentUploader(cdn: _cdnClient);

final feedsApi = api.DefaultApi(httpClient);
final feedsApi = feedsRestApi ?? api.DefaultApi(httpClient);

_activitiesRepository = ActivitiesRepository(feedsApi, attachmentUploader);
_appRepository = AppRepository(feedsApi);
Expand Down
3 changes: 2 additions & 1 deletion packages/stream_feeds/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,5 @@ dev_dependencies:
json_serializable: ^6.9.5
mocktail: ^1.0.4
retrofit_generator: ^9.6.0
test: ^1.26.3
test: ^1.26.3
web_socket_channel: ^3.0.3
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import 'package:stream_feeds/src/client/feeds_client_impl.dart';
import 'package:stream_feeds/stream_feeds.dart';
import 'package:test/test.dart';

const testToken =
'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VyX2lkIjoibHVrZV9za3l3YWxrZXIifQ.hZ59SWtp_zLKVV9ShkqkTsCGi_jdPHly7XNCf5T_Ev0';
import '../mocks.dart';

void main() {
test('Create a feeds client', () {
final client = StreamFeedsClient(
Expand Down
11 changes: 11 additions & 0 deletions packages/stream_feeds/test/mocks.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,21 @@ import 'package:mocktail/mocktail.dart';
import 'package:stream_feeds/src/client/feeds_client_impl.dart';
import 'package:stream_feeds/src/repository/feeds_repository.dart';
import 'package:stream_feeds/stream_feeds.dart';
import 'package:stream_feeds/stream_feeds.dart' as api;
import 'package:web_socket_channel/web_socket_channel.dart';

class MockFeedsRepository extends Mock implements FeedsRepository {}

class MockFeedsClient extends Mock implements StreamFeedsClient {}

class MockWebSocketClient extends Mock implements StreamWebSocketClient {}

class MockDefaultApi extends Mock implements api.DefaultApi {}

class MockWebSocketChannel extends Mock implements WebSocketChannel {}

class MockWebSocketSink extends Mock implements WebSocketSink {}

class FakeFeedsClient extends Fake implements StreamFeedsClientImpl {
FakeFeedsClient({
User? user,
Expand All @@ -25,3 +33,6 @@ const fakeUser = User(
id: 'user_id',
name: 'user_name',
);

const testToken =
'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VyX2lkIjoibHVrZV9za3l3YWxrZXIifQ.hZ59SWtp_zLKVV9ShkqkTsCGi_jdPHly7XNCf5T_Ev0';
Loading