zjsunit: Do not run $(...) automatically.

We have generally gone away from using $(...)
initialization in modules that we test with
zjsunit, but there are a few remaining special
cases related to our billing and portico
codebases.
This commit is contained in:
Steve Howell
2021-03-13 14:49:01 +00:00
committed by Steve Howell
parent bc8647539c
commit fbd3669461
8 changed files with 33 additions and 9 deletions

View File

@@ -22,6 +22,8 @@ const helpers = mock_esm("../../static/js/billing/helpers", {
set_tab: () => {},
});
zrequire("billing/billing");
run_test("initialize", (override) => {
let token_func;
@@ -69,7 +71,7 @@ run_test("initialize", (override) => {
$("#payment-method").data = (key) =>
document.querySelector("#payment-method").getAttribute("data-" + key);
zrequire("billing/billing");
$.get_initialize_function()();
assert(set_tab_called);
assert(stripe_checkout_configure_called);

View File

@@ -16,7 +16,9 @@ const common = zrequire("common");
run_test("basics", () => {
common.autofocus("#home");
$.get_initialize_function()();
assert($("#home").is_focused());
$.clear_initialize_function();
});
run_test("phrase_match", () => {

View File

@@ -8,7 +8,7 @@ const {run_test} = require("../zjsunit/test");
const $ = require("../zjsunit/zjquery");
const noop = () => {};
stub_templates(() => noop);
stub_templates(() => "<stub>");
const page_params = set_global("page_params", {});
mock_cjs("jquery", $);

View File

@@ -14,9 +14,10 @@ const dom = new JSDOM(template, {pretendToBeVisual: true});
const document = dom.window.document;
mock_cjs("jquery", $);
zrequire("../js/analytics/support");
run_test("scrub_realm", () => {
zrequire("../js/analytics/support");
$.get_initialize_function()();
const click_handler = $("body").get_on_handler("click", ".scrub-realm-button");
const fake_this = $.create("fake-.scrub-realm-button");

View File

@@ -28,6 +28,7 @@ set_global("page_params", {
mock_cjs("jquery", $);
const helpers = zrequire("../js/billing/helpers");
zrequire("../js/billing/upgrade");
run_test("initialize", (override) => {
let token_func;
@@ -103,7 +104,7 @@ run_test("initialize", (override) => {
$("#autopay-form").data = (key) =>
document.querySelector("#autopay-form").getAttribute("data-" + key);
zrequire("../js/billing/upgrade");
$.get_initialize_function()();
const e = {
preventDefault: noop,