platform/packages/framework/test/find_one_test.dart
2021-05-14 18:34:09 +08:00

25 lines
723 B
Dart

import 'package:angel3_framework/angel3_framework.dart';
import 'package:test/test.dart';
import 'common.dart';
void main() {
var throwsAnAngelHttpException =
throwsA(const IsInstanceOf<AngelHttpException>());
/*
test('throw 404 on null', () {
var service = AnonymousService(index: ([p]) => null);
expect(() => service.findOne(), throwsAnAngelHttpException);
});
*/
test('throw 404 on empty iterable', () {
var service = AnonymousService(index: ([p]) => []);
expect(() => service.findOne(), throwsAnAngelHttpException);
});
test('return first element of iterable', () async {
var service = AnonymousService(index: ([p]) => [2]);
expect(await service.findOne(), 2);
});
}