Skip to content

armgit / zulip

Public Imported from GitHub
0

Zulip server and web application. Open-source team chat that helps teams stay productive and focused.

node tests: Clean up robust_uri_decode.

Steve Howellf5488b98eba5
diff --git a/frontend_tests/node_tests/util.js b/frontend_tests/node_tests/util.js
index efe82afe483..d34c6786568 100644
--- a/frontend_tests/node_tests/util.js
+++ b/frontend_tests/node_tests/util.js
@@ -110,14 +110,23 @@ run_test("robust_uri_decode", () => {
assert.equal(util.robust_uri_decode("xxx%3Ayyy"), "xxx:yyy");
assert.equal(util.robust_uri_decode("xxx%3"), "xxx");
- set_global("decodeURIComponent", () => {
- throw new Error("foo");
- });
- try {
- util.robust_uri_decode("%E0%A4%A");
- } catch (error) {
- assert.equal(error.message, "foo");
- }
+ let error_message;
+ with_field(
+ global,
+ "decodeURIComponent",
+ () => {
+ throw new Error("foo");
+ },
+ () => {
+ try {
+ util.robust_uri_decode("%E0%A4%A");
+ } catch (error) {
+ error_message = error.message;
+ }
+ },
+ );
+
+ assert.equal(error_message, "foo");
});
run_test("dumb_strcmp", () => {