2018-07-12 15:19:25 +00:00
|
|
|
import 'package:angel_framework/angel_framework.dart';
|
|
|
|
import 'package:test/test.dart';
|
|
|
|
import 'common.dart';
|
|
|
|
|
|
|
|
void main() {
|
|
|
|
var throwsAnAngelHttpException =
|
|
|
|
throwsA(const IsInstanceOf<AngelHttpException>());
|
|
|
|
|
|
|
|
test('throw 404 on null', () {
|
2019-05-02 22:48:31 +00:00
|
|
|
var service = AnonymousService(index: ([p]) => null);
|
2018-07-12 15:19:25 +00:00
|
|
|
expect(() => service.findOne(), throwsAnAngelHttpException);
|
|
|
|
});
|
|
|
|
|
|
|
|
test('throw 404 on empty iterable', () {
|
2019-05-02 22:48:31 +00:00
|
|
|
var service = AnonymousService(index: ([p]) => []);
|
2018-07-12 15:19:25 +00:00
|
|
|
expect(() => service.findOne(), throwsAnAngelHttpException);
|
|
|
|
});
|
|
|
|
|
|
|
|
test('return first element of iterable', () async {
|
2019-05-02 22:48:31 +00:00
|
|
|
var service = AnonymousService(index: ([p]) => [2]);
|
2018-07-12 15:19:25 +00:00
|
|
|
expect(await service.findOne(), 2);
|
|
|
|
});
|
|
|
|
}
|