Mercurial > hg > nginx-tests
comparison js_variables.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 |
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_set $test_var test_var; | 38 js_set $test_var test.variable; |
39 | 39 |
40 js_include test.js; | 40 js_import test.js; |
41 | 41 |
42 server { | 42 server { |
43 listen 127.0.0.1:8080; | 43 listen 127.0.0.1:8080; |
44 server_name localhost; | 44 server_name localhost; |
45 | 45 |
46 set $foo foo_orig; | 46 set $foo test.foo_orig; |
47 | 47 |
48 location /var_set { | 48 location /var_set { |
49 return 200 $test_var$foo; | 49 return 200 $test_var$foo; |
50 } | 50 } |
51 | 51 |
52 location /content_set { | 52 location /content_set { |
53 js_content content_set; | 53 js_content test.content_set; |
54 } | 54 } |
55 | 55 |
56 location /not_found_set { | 56 location /not_found_set { |
57 js_content not_found_set; | 57 js_content test.not_found_set; |
58 } | 58 } |
59 } | 59 } |
60 } | 60 } |
61 | 61 |
62 EOF | 62 EOF |
63 | 63 |
64 $t->write_file('test.js', <<EOF); | 64 $t->write_file('test.js', <<EOF); |
65 function test_var(r) { | 65 function variable(r) { |
66 r.variables.foo = r.variables.arg_a; | 66 r.variables.foo = r.variables.arg_a; |
67 return 'test_var'; | 67 return 'test_var'; |
68 } | 68 } |
69 | 69 |
70 function content_set(r) { | 70 function content_set(r) { |
78 } catch (e) { | 78 } catch (e) { |
79 r.return(500, e); | 79 r.return(500, e); |
80 } | 80 } |
81 } | 81 } |
82 | 82 |
83 export default {variable, content_set, not_found_set}; | |
84 | |
83 EOF | 85 EOF |
84 | 86 |
85 $t->try_run('no njs')->plan(3); | 87 $t->try_run('no njs')->plan(3); |
86 | 88 |
87 ############################################################################### | 89 ############################################################################### |