platform/packages/foundation/test/find_one_test.dart

26 lines
702 B
Dart
Raw Permalink Normal View History

import 'package:platform_foundation/core.dart';
import 'package:test/test.dart';
import 'common.dart';
void main() {
2024-09-28 23:14:48 +00:00
var throwsAnHttpException =
throwsA(const IsInstanceOf<PlatformHttpException>());
/*
test('throw 404 on null', () {
var service = AnonymousService(index: ([p]) => null);
expect(() => service.findOne(), throwsAnHttpException);
});
*/
test('throw 404 on empty iterable', () {
var service = AnonymousService(index: ([p]) => []);
expect(() => service.findOne(), throwsAnHttpException);
});
test('return first element of iterable', () async {
var service = AnonymousService(index: ([p]) => [2]);
expect(await service.findOne(), 2);
});
}