Tests: TODO js_internal_redirect.t on njs < 0.2.2.
On older njs versions, js runtime exception is thrown:
"TypeError: cannot find property 'internalRedirect' of an external object".
diff --git a/js_internal_redirect.t b/js_internal_redirect.t
index ab078d6..3946b46 100644
--- a/js_internal_redirect.t
+++ b/js_internal_redirect.t
@@ -43,6 +43,10 @@
listen 127.0.0.1:8080;
server_name localhost;
+ location /njs {
+ js_content test_njs;
+ }
+
location /test {
js_content test_redirect;
}
@@ -61,6 +65,10 @@
EOF
$t->write_file('test.js', <<EOF);
+ function test_njs(r) {
+ r.return(200, njs.version);
+ }
+
function test_redirect(req) {
if (req.variables.arg_dest.startsWith('named')) {
req.internalRedirect('\@named');
@@ -77,12 +85,18 @@
EOF
-$t->try_run('no njs internalRedirect')->plan(3);
+$t->try_run('no njs available')->plan(3);
###############################################################################
+TODO: {
+local $TODO = 'no njs internalRedirect'
+ unless http_get('/njs') =~ /^([.0-9]+)$/m && $1 ge '0.2.2';
+
like(http_get('/test'), qr/redirect/s, 'redirect');
like(http_get('/test?a=A'), qr/redirectA/s, 'redirect with args');
like(http_get('/test?dest=named'), qr/named/s, 'redirect to named location');
+}
+
###############################################################################