Skip to content

Commit

Permalink
chore: add tests for redirect
Browse files Browse the repository at this point in the history
  • Loading branch information
codekeyz committed Feb 4, 2024
1 parent 2071f9b commit 1f5ed04
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions packages/pharaoh/test/http/res.redirect_test.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import 'dart:io';

import 'package:pharaoh/pharaoh.dart';
import 'package:spookie/spookie.dart';

void main() {
group('res.redirect', () {
test('should redirect to paths on the api', () async {
final app = Pharaoh()
..get('/bar', (_, res) => res.ok('Finally here!'))
..get('/foo', (_, res) => res.redirect('/bar', 301));

await (await request<Pharaoh>(app))
.get('/foo')
.expectStatus(HttpStatus.ok)
.expectBody("Finally here!")
.test();
});

test('should redirect to remote paths', () async {
final app = Pharaoh()
..get('/foo', (_, res) => res.redirect('https://example.com', 301));

await (await request<Pharaoh>(app))
.get('/foo')
.expectStatus(HttpStatus.ok)
.expectBody(contains('Example Domain'))
.test();
});
});
}

0 comments on commit 1f5ed04

Please sign in to comment.