platform/packages/framework/test/extension_test.dart

33 lines
960 B
Dart
Raw Normal View History

2017-11-28 18:14:50 +00:00
import 'dart:async';
2021-05-14 10:34:09 +00:00
import 'package:angel3_container/mirrors.dart';
import 'package:angel3_framework/angel3_framework.dart';
import 'package:angel3_framework/http.dart';
import 'package:angel3_mock_request/angel3_mock_request.dart';
2017-11-28 18:14:50 +00:00
import 'package:test/test.dart';
final Uri ENDPOINT = Uri.parse('http://example.com');
2021-05-14 10:34:09 +00:00
void main() {
2017-11-28 18:14:50 +00:00
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
}