platform/test/precontained_test.dart

25 lines
722 B
Dart
Raw Normal View History

2017-06-06 12:42:33 +00:00
import 'dart:convert';
import 'package:angel_framework/angel_framework.dart';
import 'package:mock_request/mock_request.dart';
import 'package:test/test.dart';
main() {
test('preinjects functions', () async {
var app = new Angel()
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;
var body = await rs.transform(UTF8.decoder).join();
expect(body, JSON.encode('bar'));
});
}
echoAppFoo(String foo) => foo;