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>());
|
|
|
|
|
2021-04-04 14:26:58 +00:00
|
|
|
/*
|
2018-07-12 15:19:25 +00:00
|
|
|
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);
|
|
|
|
});
|
2021-04-04 14:26:58 +00:00
|
|
|
*/
|
2018-07-12 15:19:25 +00:00
|
|
|
|
|
|
|
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);
|
|
|
|
});
|
|
|
|
}
|