Skip to content

Commit

Permalink
Merge pull request #479 from foretagsplatsen/32129139/Import_jquery_i…
Browse files Browse the repository at this point in the history
…nstead_of_using_a_global

32129139: Import jquery instead of using a global
  • Loading branch information
DamienCassou authored Apr 5, 2024
2 parents 64478f7 + a31979e commit 6bcdb0a
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 4 deletions.
5 changes: 5 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
/* eslint-env commonjs */

module.exports = {
root: true,
extends: ["plugin:@foretagsplatsen/main"],
// workaround for plugin:@foretagsplatsen/main enabling many
// unwanted environments:
env: { amd: false, jquery: false, node: false, jasmine: false },
rules: {
"import/no-unused-modules": [
"error",
Expand Down
1 change: 1 addition & 0 deletions src/router/url.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { object } from "klassified";
import jQuery from "../lib-wrappers/jquery.js";

/**
* Token/Char used to separate segments in URL paths.
Expand Down
3 changes: 3 additions & 0 deletions src/test/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
/* eslint-env commonjs */

module.exports = {
env: { jasmine: true },
rules: {
"import/no-unused-modules": "off",
},
Expand Down
6 changes: 3 additions & 3 deletions src/test/htmlCanvasTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import htmlCanvas from "../htmlCanvas.js";
import jQuery from "../lib-wrappers/jquery.js";

function withCanvas(callback) {
$("BODY").append('<div id="sandbox"></div>');
jQuery("BODY").append('<div id="sandbox"></div>');
let sandbox = jQuery("#sandbox");

let html = htmlCanvas(sandbox);
Expand All @@ -24,7 +24,7 @@ describe("htmlCanvas", () => {
expect(html).toBeTruthy();
expect(html.root).toBeTruthy();
expect(html.root.element).toBeTruthy();
expect($("BODY").is(html.root.element)).toBeTruthy();
expect(jQuery("BODY").is(html.root.element)).toBeTruthy();
});

it("throws exception if jQuery dont match element", () => {
Expand Down Expand Up @@ -266,7 +266,7 @@ describe("htmlCanvas", () => {
withCanvas((html) => {
// Arrange a div with10 sub span supplied to DIV as an array
html.div(
$.map([1, 2, 3, 4, 5, 6, 7, 8, 9, 10], (num) =>
jQuery.map([1, 2, 3, 4, 5, 6, 7, 8, 9, 10], (num) =>
html.span(num.toString()),
),
).id("test_div");
Expand Down
2 changes: 1 addition & 1 deletion src/test/widgetTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ function withWidget(callback) {
}

function withCanvas(callback) {
$("BODY").append('<div id="sandbox"></div>');
jQuery("BODY").append('<div id="sandbox"></div>');
let sandbox = jQuery("#sandbox");

let html = htmlCanvas(sandbox);
Expand Down

0 comments on commit 6bcdb0a

Please sign in to comment.