diff --git a/test/unit/server_subscription_test.dart b/test/unit/server_subscription_test.dart index 412ce6c..e64ac48 100644 --- a/test/unit/server_subscription_test.dart +++ b/test/unit/server_subscription_test.dart @@ -5,76 +5,79 @@ import 'package:test/test.dart'; void main() { group('SpinifyServerSubscription', () { test( - 'Emulate server subscription', - () => fakeAsync((async) { - final client = Spinify( - config: SpinifyConfig( - transportBuilder: $createFakeSpinifyTransport( - overrideCommand: (command) => switch (command) { - SpinifyConnectRequest request => SpinifyConnectResult( + 'Emulate server subscription', + () => fakeAsync( + (async) { + final client = Spinify( + config: SpinifyConfig( + transportBuilder: $createFakeSpinifyTransport( + overrideCommand: (command) => switch (command) { + SpinifyConnectRequest request => SpinifyConnectResult( + id: request.id, + timestamp: DateTime.now(), + client: 'fake', + version: '0.0.1', + expires: false, + ttl: null, + data: null, + subs: { + 'notification:index': SpinifySubscribeResult( id: request.id, timestamp: DateTime.now(), - client: 'fake', - version: '0.0.1', + data: const [], expires: false, ttl: null, - data: null, - subs: { - 'notification:index': SpinifySubscribeResult( - id: request.id, - timestamp: DateTime.now(), + positioned: false, + publications: [ + SpinifyPublication( + channel: 'notification:index', data: const [], - expires: false, - ttl: null, - positioned: false, - publications: [ - SpinifyPublication( - channel: 'notification:index', - data: const [], - info: SpinifyClientInfo( - client: 'fake', - user: 'fake', - channelInfo: const [], - connectionInfo: const [], - ), - timestamp: DateTime.now(), - tags: const { - 'type': 'notification', - }, - offset: Int64.ZERO, - ), - ], - recoverable: false, - recovered: false, - since: (epoch: '...', offset: Int64.ZERO), - wasRecovering: false, + info: SpinifyClientInfo( + client: 'fake', + user: 'fake', + channelInfo: const [], + connectionInfo: const [], + ), + timestamp: DateTime.now(), + tags: const { + 'type': 'notification', + }, + offset: Int64.ZERO, ), - }, - pingInterval: const Duration(seconds: 25), - sendPong: false, - session: 'fake', - node: 'fake', + ], + recoverable: false, + recovered: false, + since: (epoch: '...', offset: Int64.ZERO), + wasRecovering: false, ), - _ => null, - }, - ), - ), - )..connect('ws://localhost:8000/connection/websocket'); - async.elapse(client.config.timeout); - expect( - client.subscriptions.server, - isA>() - .having( - (s) => s.length, - 'length', - 1, - ) - .having( - (s) => s['notification:index'], - 'notification:index', - isA(), + }, + pingInterval: const Duration(seconds: 25), + sendPong: false, + session: 'fake', + node: 'fake', ), - ); - })); + _ => null, + }, + ), + ), + )..connect('ws://localhost:8000/connection/websocket'); + async.elapse(client.config.timeout); + expect( + client.subscriptions.server, + isA>() + .having( + (s) => s.length, + 'length', + 1, + ) + .having( + (s) => s['notification:index'], + 'notification:index', + isA(), + ), + ); + }, + ), + ); }); }