Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
node tests: Add test() wrapper for typing_data.
Steve Howell09bad82131ab
diff --git a/frontend_tests/node_tests/typing_data.js b/frontend_tests/node_tests/typing_data.jsindex 318fd789a87..d923d94c55d 100644--- a/frontend_tests/node_tests/typing_data.js+++ b/frontend_tests/node_tests/typing_data.js@@ -7,7 +7,14 @@ const {run_test} = require("../zjsunit/test");const typing_data = zrequire("typing_data");-run_test("basics", () => {+function test(label, f) {+ run_test(label, (override) => {+ typing_data.clear_for_testing();+ f(override);+ });+}++test("basics", () => {// The typing_data needs to be robust with lists of// user ids being in arbitrary sorting order and// possibly in string form instead of integer. So all@@ -52,7 +59,7 @@ run_test("basics", () => {assert.deepEqual(typing_data.get_group_typists([20, 40]), [20]);});-run_test("timers", () => {+test("timers", () => {const events = {};const stub_timer_id = "timer_id_stub";diff --git a/static/js/typing_data.js b/static/js/typing_data.jsindex 9862957969f..1c39d705881 100644--- a/static/js/typing_data.js+++ b/static/js/typing_data.js@@ -7,6 +7,11 @@ import * as util from "./util";const typist_dct = new Map();const inbound_timer_dict = new Map();+export function clear_for_testing() {+ typist_dct.clear();+ inbound_timer_dict.clear();+}+function to_int(s) {return Number.parseInt(s, 10);}