platform/test/find_one_test.dart

24 lines
723 B
Dart
Raw Normal View History

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', () {
var service = new AnonymousService(index: ([p]) => null);
expect(() => service.findOne(), throwsAnAngelHttpException);
});
test('throw 404 on empty iterable', () {
var service = new AnonymousService(index: ([p]) => []);
expect(() => service.findOne(), throwsAnAngelHttpException);
});
test('return first element of iterable', () async {
var service = new AnonymousService(index: ([p]) => [2]);
expect(await service.findOne(), 2);
});
}