platform/packages/core/test/precontained_test.dart

29 lines
907 B
Dart
Raw Permalink Normal View History

import 'dart:convert';
import 'package:platform_container/mirrors.dart';
import 'package:platform_core/core.dart';
import 'package:platform_core/http.dart';
import 'package:platform_mocking/mocking.dart';
import 'package:test/test.dart';
void main() {
test('preinjects functions', () async {
2024-09-28 23:14:48 +00:00
var app = Application(reflector: MirrorsReflector())
..configuration['foo'] = 'bar'
..get('/foo', ioc(echoAppFoo));
app.optimizeForProduction(force: true);
print(app.preContained);
expect(app.preContained.keys, contains(echoAppFoo));
var rq = MockHttpRequest('GET', Uri(path: '/foo'));
await rq.close();
2024-09-28 23:14:48 +00:00
await PlatformHttp(app).handleRequest(rq);
var rs = rq.response;
var body = await rs.transform(utf8.decoder).join();
expect(body, json.encode('bar'));
}, skip: 'Protevus no longer has to preinject functions');
}
String echoAppFoo(String foo) => foo;