node tests: Add test() wrapper for reload_state.

This is kinda overkill for such a tiny test, but
it should future-proof us from intra-test leaks.
This commit is contained in:
Steve Howell 2021-03-22 18:45:29 +00:00 committed by Steve Howell
parent 855ac26c48
commit 56698d4a9a
1 changed files with 9 additions and 2 deletions

View File

@ -7,13 +7,20 @@ const {run_test} = require("../zjsunit/test");
const reload_state = zrequire("reload_state");
run_test("set_state_to_pending", () => {
function test(label, f) {
run_test(label, (override) => {
reload_state.clear_for_testing();
f(override);
});
}
test("set_state_to_pending", () => {
assert(!reload_state.is_pending());
reload_state.set_state_to_pending();
assert(reload_state.is_pending());
});
run_test("set_state_to_in_progress", () => {
test("set_state_to_in_progress", () => {
assert(!reload_state.is_in_progress());
reload_state.set_state_to_in_progress();
assert(reload_state.is_in_progress());