comparison js_dump.t @ 1614:bc0990ea2e5b

Tests: js TODO adjusted up to 0.4.0.
author Dmitry Volyntsev <xeioex@nginx.com>
date Tue, 17 Nov 2020 17:49:16 +0000
parents 96fb3513345b
children c56df3527161
comparison
equal deleted inserted replaced
1613:d7ec131d305a 1614:bc0990ea2e5b
40 40
41 server { 41 server {
42 listen 127.0.0.1:8080; 42 listen 127.0.0.1:8080;
43 server_name localhost; 43 server_name localhost;
44 44
45 location /njs {
46 js_content test_njs;
47 }
48
49 location /dump { 45 location /dump {
50 js_content test_dump; 46 js_content test_dump;
51 } 47 }
52 48
53 location /stringify { 49 location /stringify {
65 } 61 }
66 62
67 EOF 63 EOF
68 64
69 $t->write_file('test.js', <<EOF); 65 $t->write_file('test.js', <<EOF);
70 function test_njs(r) {
71 r.return(200, njs.version);
72 }
73
74 function test_dump(r) { 66 function test_dump(r) {
75 r.headersOut.baz = 'bar'; 67 r.headersOut.baz = 'bar';
76 r.return(200, njs.dump(r)); 68 r.return(200, njs.dump(r));
77 } 69 }
78 70
92 84
93 $t->try_run('no njs dump')->plan(3); 85 $t->try_run('no njs dump')->plan(3);
94 86
95 ############################################################################### 87 ###############################################################################
96 88
97 TODO: {
98 local $TODO = 'not yet'
99 unless http_get('/njs') =~ /^([.0-9]+)$/m && $1 ge '0.3.8';
100
101 like(http( 89 like(http(
102 'GET /dump?v=1&t=x HTTP/1.0' . CRLF 90 'GET /dump?v=1&t=x HTTP/1.0' . CRLF
103 . 'Foo: bar' . CRLF 91 . 'Foo: bar' . CRLF
104 . 'Foo2: bar2' . CRLF 92 . 'Foo2: bar2' . CRLF
105 . 'Host: localhost' . CRLF . CRLF 93 . 'Host: localhost' . CRLF . CRLF
115 like(http( 103 like(http(
116 'GET /stringify_subrequest HTTP/1.0' . CRLF 104 'GET /stringify_subrequest HTTP/1.0' . CRLF
117 . 'Host: localhost' . CRLF . CRLF 105 . 'Host: localhost' . CRLF . CRLF
118 ), qr/responseBody":"\{GET}"/, 'JSON.stringify(reply)'); 106 ), qr/responseBody":"\{GET}"/, 'JSON.stringify(reply)');
119 107
120 }
121
122 ############################################################################### 108 ###############################################################################