2024-09-23 01:44:59 +00:00
|
|
|
import 'dart:async';
|
|
|
|
import 'package:platform_container/mirrors.dart';
|
2024-09-25 04:04:57 +00:00
|
|
|
import 'package:platform_core/core.dart';
|
|
|
|
import 'package:platform_core/http.dart';
|
2024-11-11 19:49:32 +00:00
|
|
|
import 'package:platform_testing/http.dart';
|
2024-09-23 01:44:59 +00:00
|
|
|
import 'package:test/test.dart';
|
|
|
|
|
|
|
|
final Uri endpoint = Uri.parse('http://example.com');
|
|
|
|
|
|
|
|
void 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 = MockHttpRequest('GET', endpoint.replace(path: path))..close();
|
2024-09-28 23:14:48 +00:00
|
|
|
var app = Application(reflector: MirrorsReflector());
|
|
|
|
var http = PlatformHttp(app);
|
2024-09-23 01:44:59 +00:00
|
|
|
return http.createRequestContext(rq, rq.response);
|
|
|
|
}
|