zjquery: Make zjquery a singleton.

We no longer export make_zjquery().

We now instead have a singleton zjquery instance
that we attach to global.$ in index.js.

We call $.clear_all_elements() before each module.
(We will soon get even more aggressive about doing
it in run_test.)

Test functions can still override $ with set_global.
A good example of this is copy_and_paste using the
real jquery module.

We no longer exempt $ as a global variable, so
test modules that use the zjquery $ need to do:

    const $ = require("../zjsunit/zjquery");
This commit is contained in:
Steve Howell
2021-02-21 14:38:51 +00:00
committed by Steve Howell
parent 2e3406f0b8
commit 64c7eb67eb
68 changed files with 79 additions and 172 deletions

View File

@@ -4,9 +4,7 @@ const {strict: assert} = require("assert");
const {set_global, with_field, zrequire} = require("../zjsunit/namespace");
const {run_test} = require("../zjsunit/test");
const {make_zjquery} = require("../zjsunit/zjquery");
set_global("$", make_zjquery());
const $ = require("../zjsunit/zjquery");
const narrow_state = set_global("narrow_state", {});
set_global("ui", {