Skip to content

Commit c1cd537

Browse files
committed
chore(test): centralize mock definitions
This commit refactors test utilities by moving `MockWebSocketSink` from `web_socket_mocks.dart` to the centralized `mocks.dart` file. This change avoids duplicating mock definitions and improves the organization of test helper code. The `whenListenWebSocket` function has been updated to use the centrally defined mocks.
1 parent 7210bcc commit c1cd537

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

packages/stream_feeds/test/test_utils/mocks.dart

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ import 'package:web_socket_channel/web_socket_channel.dart';
66

77
class MockDefaultApi extends Mock implements api.DefaultApi {}
88

9+
class MockWebSocketSink extends Mock implements WebSocketSink {}
10+
911
class MockWebSocketChannel extends Mock implements WebSocketChannel {}
1012

1113
api.UserToken generateTestUserToken(String userId) {

packages/stream_feeds/test/test_utils/web_socket_mocks.dart

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,8 @@ import 'dart:convert';
33

44
import 'package:mocktail/mocktail.dart';
55
import 'package:stream_feeds/src/ws/events/events.dart';
6-
import 'package:web_socket_channel/web_socket_channel.dart';
76

8-
class _MockWebSocketSink extends Mock implements WebSocketSink {}
7+
import 'mocks.dart';
98

109
/// Sets up WebSocket channel mocks for testing.
1110
///
@@ -20,10 +19,10 @@ class _MockWebSocketSink extends Mock implements WebSocketSink {}
2019
/// whenListenWebSocket(webSocketChannel, wsStreamController);
2120
/// ```
2221
void whenListenWebSocket(
23-
WebSocketChannel webSocketChannel,
22+
MockWebSocketChannel webSocketChannel,
2423
StreamController<Object> wsStreamController,
2524
) {
26-
final webSocketSink = _MockWebSocketSink();
25+
final webSocketSink = MockWebSocketSink();
2726

2827
when(
2928
webSocketSink.close,

0 commit comments

Comments
 (0)