platform/test/extension_test.dart

33 lines
937 B
Dart
Raw Normal View History

2017-11-28 18:14:50 +00:00
import 'dart:async';
2018-08-19 15:33:25 +00:00
import 'package:angel_container/mirrors.dart';
2017-11-28 18:14:50 +00:00
import 'package:angel_framework/angel_framework.dart';
2018-10-22 15:54:41 +00:00
import 'package:angel_framework/http.dart';
2017-11-28 18:14:50 +00:00
import 'package:mock_request/mock_request.dart';
import 'package:test/test.dart';
final Uri ENDPOINT = Uri.parse('http://example.com');
main() {
test('single extension', () async {
var req = await makeRequest('foo.js');
expect(req.extension, '.js');
});
test('multiple extensions', () async {
var req = await makeRequest('foo.min.js');
expect(req.extension, '.js');
});
test('no extension', () async {
var req = await makeRequest('foo');
expect(req.extension, '');
});
}
Future<RequestContext> makeRequest(String path) {
2019-05-02 22:48:31 +00:00
var rq = MockHttpRequest('GET', ENDPOINT.replace(path: path))..close();
var app = Angel(reflector: MirrorsReflector());
var http = AngelHttp(app);
2018-11-11 01:07:09 +00:00
return http.createRequestContext(rq, rq.response);
2017-11-28 18:14:50 +00:00
}