platform/packages/framework/test/find_one_test.dart

26 lines
723 B
Dart
Raw Normal View History

2021-05-14 10:34:09 +00:00
import 'package:angel3_framework/angel3_framework.dart';
2018-07-12 15:19:25 +00:00
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);
});
}