diff js_subrequests.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 5ac6efbe5552
children f89770df737a
line wrap: on
line diff
--- a/js_subrequests.t
+++ b/js_subrequests.t
@@ -43,70 +43,70 @@ http {
     proxy_cache_path   %%TESTDIR%%/cache1
                        keys_zone=ON:1m      use_temp_path=on;
 
-    js_include test.js;
+    js_import test.js;
 
-    js_set $async_var       async_var;
-    js_set $subrequest_var  subrequest_var;
+    js_set $async_var       test.async_var;
+    js_set $subrequest_var  test.subrequest_var;
 
     server {
         listen       127.0.0.1:8080;
         server_name  localhost;
 
         location /njs {
-            js_content test_njs;
+            js_content test.njs;
         }
 
         location /sr {
-            js_content sr;
+            js_content test.sr;
         }
 
         location /sr_pr {
-            js_content sr_pr;
+            js_content test.sr_pr;
         }
 
         location /sr_args {
-            js_content sr_args;
+            js_content test.sr_args;
         }
 
         location /sr_options_args {
-            js_content sr_options_args;
+            js_content test.sr_options_args;
         }
 
         location /sr_options_args_pr {
-            js_content sr_options_args_pr;
+            js_content test.sr_options_args_pr;
         }
 
         location /sr_options_method {
-            js_content sr_options_method;
+            js_content test.sr_options_method;
         }
 
         location /sr_options_method_pr {
-            js_content sr_options_method_pr;
+            js_content test.sr_options_method_pr;
         }
 
         location /sr_options_body {
-            js_content sr_options_body;
+            js_content test.sr_options_body;
         }
 
         location /sr_options_method_head {
-            js_content sr_options_method_head;
+            js_content test.sr_options_method_head;
         }
 
         location /sr_body {
-            js_content sr_body;
+            js_content test.sr_body;
         }
 
         location /sr_body_pr {
-            js_content sr_body_pr;
+            js_content test.sr_body_pr;
         }
 
         location /sr_body_special {
-            js_content sr_body_special;
+            js_content test.sr_body_special;
         }
 
         location /sr_in_variable_handler {
             set $_ $async_var;
-            js_content sr_in_variable_handler;
+            js_content test.sr_in_variable_handler;
         }
 
         location /sr_detached_in_variable_handler {
@@ -120,64 +120,64 @@ http {
         }
 
         location /sr_error_page {
-            js_content sr_error_page;
+            js_content test.sr_error_page;
         }
 
         location /sr_js_in_subrequest {
-            js_content sr_js_in_subrequest;
+            js_content test.sr_js_in_subrequest;
         }
 
         location /sr_js_in_subrequest_pr {
-            js_content sr_js_in_subrequest_pr;
+            js_content test.sr_js_in_subrequest_pr;
         }
 
         location /sr_file {
-            js_content sr_file;
+            js_content test.sr_file;
         }
 
         location /sr_cache {
-            js_content sr_cache;
+            js_content test.sr_cache;
         }
 
 
         location /sr_unavail {
-            js_content sr_unavail;
+            js_content test.sr_unavail;
         }
 
         location /sr_unavail_pr {
-            js_content sr_unavail_pr;
+            js_content test.sr_unavail_pr;
         }
 
         location /sr_broken {
-            js_content sr_broken;
+            js_content test.sr_broken;
         }
 
         location /sr_too_large {
-            js_content sr_too_large;
+            js_content test.sr_too_large;
         }
 
         location /sr_out_of_order {
-            js_content sr_out_of_order;
+            js_content test.sr_out_of_order;
         }
 
         location /sr_except_not_a_func {
-            js_content sr_except_not_a_func;
+            js_content test.sr_except_not_a_func;
         }
 
         location /sr_except_failed_to_convert_options_arg {
-            js_content sr_except_failed_to_convert_options_arg;
+            js_content test.sr_except_failed_to_convert_options_arg;
         }
 
         location /sr_except_invalid_options_header_only {
-            js_content sr_except_invalid_options_header_only;
+            js_content test.sr_except_invalid_options_header_only;
         }
 
         location /sr_in_sr_callback {
-            js_content sr_in_sr_callback;
+            js_content test.sr_in_sr_callback;
         }
 
         location /sr_uri_except {
-            js_content sr_uri_except;
+            js_content test.sr_uri_except;
         }
 
 
@@ -200,7 +200,7 @@ http {
         }
 
         location /sr_in_sr {
-            js_content sr_in_sr;
+            js_content test.sr_in_sr;
         }
 
         location /unavail {
@@ -208,11 +208,11 @@ http {
         }
 
         location /sr_parent {
-             js_content sr_parent;
+             js_content test.sr_parent;
         }
 
         location /js_sub {
-            js_content js_sub;
+            js_content test.js_sub;
         }
 
         location /return {
@@ -244,15 +244,15 @@ http {
         }
 
         location /body {
-            js_content body;
+            js_content test.body;
         }
 
         location /detached {
-            js_content detached;
+            js_content test.detached;
         }
 
         location /delayed {
-            js_content delayed;
+            js_content test.delayed;
         }
     }
 
@@ -267,8 +267,6 @@ http {
 EOF
 
 $t->write_file('test.js', <<EOF);
-    this.Failed = {get toConvert() { return {toString(){return {};}}}};
-
     function test_njs(r) {
         r.return(200, njs.version);
     }
@@ -473,6 +471,8 @@ EOF
         r.subrequest('/sub1', 'a=1', 'b');
     }
 
+    let Failed = {get toConvert() { return {toString(){return {};}}}};
+
     function sr_except_failed_to_convert_options_arg(r) {
         r.subrequest('/sub1', {args:Failed.toConvert}, ()=>{});
     }
@@ -489,6 +489,17 @@ EOF
         r.return(200, '["JS-SUB"]');
     }
 
+    export default {njs:test_njs, sr, sr_pr, sr_args, sr_options_args,
+                    sr_options_args_pr, sr_options_method, sr_options_method_pr,
+                    sr_options_method_head, sr_options_body, sr_body,
+                    sr_body_pr, sr_body_special, body, delayed, detached,
+                    sr_in_variable_handler, async_var, sr_error_page,
+                    subrequest_var, sr_file, sr_cache, sr_unavail, sr_parent,
+                    sr_unavail_pr, sr_broken, sr_too_large, sr_in_sr,
+                    sr_js_in_subrequest, sr_js_in_subrequest_pr, js_sub,
+                    sr_in_sr_callback, sr_out_of_order, sr_except_not_a_func,
+                    sr_uri_except, sr_except_failed_to_convert_options_arg};
+
 EOF
 
 $t->write_file('t', '["SEE-THIS"]');