platform/test/extension_test.dart

33 lines
936 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) {
var rq = new MockHttpRequest('GET', ENDPOINT.replace(path: path))..close();
2018-08-20 02:40:11 +00:00
var app = new Angel(reflector: MirrorsReflector());
2018-02-07 04:34:08 +00:00
var http = new AngelHttp(app);
return http.createRequestContext(rq);
2017-11-28 18:14:50 +00:00
}