comparison js_promise.t @ 1781:386748f328b1

Tests: updated js properties deprecated since 0.5.0.
author Dmitry Volyntsev <xeioex@nginx.com>
date Tue, 02 Aug 2022 20:35:05 -0700
parents f89770df737a
children
comparison
equal deleted inserted replaced
1780:bd21a4a7c9f5 1781:386748f328b1
76 } 76 }
77 77
78 function promise(r) { 78 function promise(r) {
79 promisified_subrequest(r, '/sub_token', 'code=200&token=a') 79 promisified_subrequest(r, '/sub_token', 'code=200&token=a')
80 .then(reply => { 80 .then(reply => {
81 var data = JSON.parse(reply.responseBody); 81 var data = JSON.parse(reply.responseText);
82 82
83 if (data['token'] !== "a") { 83 if (data['token'] !== "a") {
84 throw new Error('token is not "a"'); 84 throw new Error('token is not "a"');
85 } 85 }
86 86
87 return data['token']; 87 return data['token'];
88 }) 88 })
89 .then(token => { 89 .then(token => {
90 promisified_subrequest(r, '/sub_token', 'code=200&token=b') 90 promisified_subrequest(r, '/sub_token', 'code=200&token=b')
91 .then(reply => { 91 .then(reply => {
92 var data = JSON.parse(reply.responseBody); 92 var data = JSON.parse(reply.responseText);
93 93
94 r.return(200, '{"token": "' + data['token'] + '"}'); 94 r.return(200, '{"token": "' + data['token'] + '"}');
95 }) 95 })
96 .catch(() => { 96 .catch(() => {
97 throw new Error("failed promise() test"); 97 throw new Error("failed promise() test");
103 } 103 }
104 104
105 function promise_throw(r) { 105 function promise_throw(r) {
106 promisified_subrequest(r, '/sub_token', 'code=200&token=x') 106 promisified_subrequest(r, '/sub_token', 'code=200&token=x')
107 .then(reply => { 107 .then(reply => {
108 var data = JSON.parse(reply.responseBody); 108 var data = JSON.parse(reply.responseText);
109 109
110 if (data['token'] !== "a") { 110 if (data['token'] !== "a") {
111 throw data['token']; 111 throw data['token'];
112 } 112 }
113 113
133 }); 133 });
134 } 134 }
135 135
136 function timeout(r) { 136 function timeout(r) {
137 promisified_subrequest(r, '/sub_token', 'code=200&token=R') 137 promisified_subrequest(r, '/sub_token', 'code=200&token=R')
138 .then(reply => JSON.parse(reply.responseBody)) 138 .then(reply => JSON.parse(reply.responseText))
139 .then(data => { 139 .then(data => {
140 setTimeout(timeout_cb, 50, r, '/sub_token', 'code=200&token=T'); 140 setTimeout(timeout_cb, 50, r, '/sub_token', 'code=200&token=T');
141 return data; 141 return data;
142 }) 142 })
143 .then(data => { 143 .then(data => {
151 151
152 function timeout_cb(r, url, args) { 152 function timeout_cb(r, url, args) {
153 promisified_subrequest(r, url, args) 153 promisified_subrequest(r, url, args)
154 .then(reply => { 154 .then(reply => {
155 if (global_token == '') { 155 if (global_token == '') {
156 var data = JSON.parse(reply.responseBody); 156 var data = JSON.parse(reply.responseText);
157 157
158 global_token = data['token']; 158 global_token = data['token'];
159 159
160 r.return(200, '{"token": "' + data['token'] + '"}'); 160 r.return(200, '{"token": "' + data['token'] + '"}');
161 } 161 }