comparison js_internal_redirect.t @ 1751:18ac4d9e5a2a

Tests: rewriting njs tests without deprecated "js_include".
author Dmitry Volyntsev <xeioex@nginx.com>
date Thu, 09 Dec 2021 17:36:29 +0000
parents bc0990ea2e5b
children ce8b0c9452ae
comparison
equal deleted inserted replaced
1750:b28f88e352dd 1751:18ac4d9e5a2a
33 } 33 }
34 34
35 http { 35 http {
36 %%TEST_GLOBALS_HTTP%% 36 %%TEST_GLOBALS_HTTP%%
37 37
38 js_include test.js; 38 js_import test.js;
39 39
40 server { 40 server {
41 listen 127.0.0.1:8080; 41 listen 127.0.0.1:8080;
42 server_name localhost; 42 server_name localhost;
43 43
44 location /test { 44 location /test {
45 js_content test_redirect; 45 js_content test.redirect;
46 } 46 }
47 47
48 location /redirect { 48 location /redirect {
49 internal; 49 internal;
50 return 200 redirect$arg_b; 50 return 200 redirect$arg_b;
57 } 57 }
58 58
59 EOF 59 EOF
60 60
61 $t->write_file('test.js', <<EOF); 61 $t->write_file('test.js', <<EOF);
62 function test_redirect(r) { 62 function redirect(r) {
63 if (r.variables.arg_dest == 'named') { 63 if (r.variables.arg_dest == 'named') {
64 r.internalRedirect('\@named'); 64 r.internalRedirect('\@named');
65 65
66 } else { 66 } else {
67 if (r.variables.arg_a) { 67 if (r.variables.arg_a) {
71 r.internalRedirect('/redirect'); 71 r.internalRedirect('/redirect');
72 } 72 }
73 } 73 }
74 } 74 }
75 75
76 export default {redirect};
77
76 EOF 78 EOF
77 79
78 $t->try_run('no njs available')->plan(3); 80 $t->try_run('no njs available')->plan(3);
79 81
80 ############################################################################### 82 ###############################################################################