platform/packages/websocket/test/service/common.dart
Tobe O c97363d290 Add 'packages/websocket/' from commit '229b5e72058a644292d0f258bd0f7f06613b7b24'
git-subtree-dir: packages/websocket
git-subtree-mainline: e887b1d21f
git-subtree-split: 229b5e7205
2020-02-15 18:28:28 -05:00

35 lines
891 B
Dart

import 'dart:async';
import 'package:angel_framework/angel_framework.dart';
import 'package:angel_model/angel_model.dart';
import 'package:angel_websocket/base_websocket_client.dart';
import 'package:angel_websocket/server.dart';
import 'package:test/test.dart';
class Todo extends Model {
String text;
String when;
Todo({String this.text, String this.when});
}
class TodoService extends MapService {
TodoService() : super() {
configuration['ws:filter'] =
(HookedServiceEvent e, WebSocketContext socket) {
print('Hello, service filter world!');
return true;
};
}
}
testIndex(BaseWebSocketClient client) async {
var todoService = client.service('api/todos');
scheduleMicrotask(() => todoService.index());
var indexed = await todoService.onIndexed.first;
print('indexed: $indexed');
expect(indexed, isList);
expect(indexed, isEmpty);
}