platform/test/precontained_test.dart

26 lines
821 B
Dart
Raw Normal View History

2018-08-19 15:33:25 +00:00
import 'package:angel_container/mirrors.dart';
2017-06-06 12:42:33 +00:00
import 'package:angel_framework/angel_framework.dart';
2018-06-08 07:06:26 +00:00
import 'package:dart2_constant/convert.dart';
2017-06-06 12:42:33 +00:00
import 'package:mock_request/mock_request.dart';
import 'package:test/test.dart';
main() {
test('preinjects functions', () async {
2018-08-20 02:40:11 +00:00
var app = new Angel(reflector: MirrorsReflector())
2017-09-24 19:43:14 +00:00
..configuration['foo'] = 'bar'
2017-06-06 12:42:33 +00:00
..get('/foo', echoAppFoo);
app.optimizeForProduction(force: true);
print(app.preContained);
expect(app.preContained, contains(echoAppFoo));
var rq = new MockHttpRequest('GET', new Uri(path: '/foo'));
rq.close();
2018-02-07 05:36:24 +00:00
await new AngelHttp(app).handleRequest(rq);
2017-06-06 12:42:33 +00:00
var rs = rq.response;
2018-06-08 07:06:26 +00:00
var body = await rs.transform(utf8.decoder).join();
expect(body, json.encode('bar'));
2017-06-06 12:42:33 +00:00
});
}
echoAppFoo(String foo) => foo;