Skip to content

Commit 23d2ce8

Browse files
committed
chore: add missing tests
1 parent 6e3f305 commit 23d2ce8

File tree

2 files changed

+23
-7
lines changed

2 files changed

+23
-7
lines changed

packages/dart_frog/test/src/request_test.dart

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import 'dart:async';
2+
import 'dart:collection';
23
import 'dart:convert';
34
import 'dart:io';
45

@@ -81,7 +82,10 @@ ${HttpMethod.values.map((m) => m.value.toUpperCase()).join(', ')}.'''),
8182

8283
test('has correct params (empty)', () {
8384
final request = Request('GET', localhost);
84-
expect(request.params, isEmpty);
85+
expect(
86+
request.params,
87+
equals(UnmodifiableMapView<String, String>(const {})),
88+
);
8589
});
8690

8791
test('body can be read multiple times (sync)', () {

packages/dart_frog/test/src/router_test.dart

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
@TestOn('vm')
1717
library;
1818

19+
import 'dart:collection';
1920
import 'dart:convert';
2021
import 'dart:io';
2122

@@ -295,7 +296,10 @@ void main() {
295296
final context = _MockRequestContext();
296297
final app = Router()
297298
..get('/hello', (RequestContext context) {
298-
expect(context.request.params, isEmpty);
299+
expect(
300+
context.request.params,
301+
equals(UnmodifiableMapView<String, String>(const {})),
302+
);
299303
return Response(body: 'hello world');
300304
});
301305

@@ -317,7 +321,10 @@ void main() {
317321
final context = _MockRequestContext();
318322
final app = Router()
319323
..get('/users/<id>/greet', (RequestContext context, String id) {
320-
expect(context.request.params['id'], equals(id));
324+
expect(
325+
context.request.params,
326+
equals(UnmodifiableMapView<String, String>({'id': id})),
327+
);
321328
return Response(body: 'hello $id');
322329
});
323330

@@ -338,10 +345,15 @@ void main() {
338345
test('request exposes captured params (multiple)', () async {
339346
final context = _MockRequestContext();
340347
final app = Router()
341-
..get('/users/<id>/greet/<name>',
342-
(RequestContext context, String id, String name) {
343-
expect(context.request.params['id'], equals(id));
344-
expect(context.request.params['name'], equals(name));
348+
..get('/users/<id>/greet/<name>', (
349+
RequestContext context,
350+
String id,
351+
String name,
352+
) {
353+
expect(
354+
context.request.params,
355+
equals(UnmodifiableMapView<String, String>({'id': id, 'name': name})),
356+
);
345357
return Response(body: 'hello $name ($id)');
346358
});
347359

0 commit comments

Comments
 (0)