2016-12-23 20:57:46 +00:00
|
|
|
import 'package:angel_framework/angel_framework.dart';
|
2017-02-22 22:34:35 +00:00
|
|
|
import 'package:angel_framework/common.dart';
|
2016-12-23 20:57:46 +00:00
|
|
|
import 'package:angel_websocket/base_websocket_client.dart';
|
2017-04-10 01:45:45 +00:00
|
|
|
import 'package:angel_websocket/server.dart';
|
2016-12-23 20:57:46 +00:00
|
|
|
import 'package:test/test.dart';
|
|
|
|
|
2017-02-22 22:34:35 +00:00
|
|
|
class Todo extends Model {
|
2016-12-23 20:57:46 +00:00
|
|
|
String text;
|
|
|
|
String when;
|
|
|
|
|
|
|
|
Todo({String this.text, String this.when});
|
|
|
|
}
|
|
|
|
|
2017-02-28 14:15:34 +00:00
|
|
|
class TodoService extends TypedService<Todo> {
|
2017-04-10 01:45:45 +00:00
|
|
|
TodoService() : super(new MapService()) {
|
2017-10-19 22:26:59 +00:00
|
|
|
configuration['ws:filter'] = (HookedServiceEvent e, WebSocketContext socket) {
|
2017-04-10 01:45:45 +00:00
|
|
|
print('Hello, service filter world!');
|
|
|
|
return true;
|
|
|
|
};
|
|
|
|
}
|
2017-02-28 14:15:34 +00:00
|
|
|
}
|
2016-12-23 20:57:46 +00:00
|
|
|
|
|
|
|
testIndex(BaseWebSocketClient client) async {
|
2017-12-21 20:15:47 +00:00
|
|
|
var Todos = client.service('api/todos');
|
2016-12-23 20:57:46 +00:00
|
|
|
Todos.index();
|
|
|
|
|
|
|
|
var indexed = await Todos.onIndexed.first;
|
2017-12-10 05:31:34 +00:00
|
|
|
print('indexed: $indexed');
|
2016-12-23 20:57:46 +00:00
|
|
|
|
2017-12-10 05:31:34 +00:00
|
|
|
expect(indexed, isList);
|
|
|
|
expect(indexed, isEmpty);
|
2016-12-23 20:57:46 +00:00
|
|
|
}
|