Skip to content

Commit ea7569f

Browse files
committed
maint(core mockup-parser): Remove jQuery dependency from tests.
1 parent fff78ae commit ea7569f

1 file changed

Lines changed: 26 additions & 19 deletions

File tree

src/core/mockup-parser.test.js

Lines changed: 26 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,45 @@
1-
import $ from "jquery";
21
import mockupParser from "./mockup-parser";
32

43
describe("The mockup-parser", function () {
54
it("parses the data attribute of a single node", function () {
6-
const $el = $(`
7-
<span data-pat-testpattern="option1: value1; option2: value2">
8-
mockup parser test
9-
</span>`);
10-
const options = mockupParser.getOptions($el, "testpattern");
5+
const el = document.createElement("div");
6+
el.setAttribute("data-pat-testpattern", "option1: value1; option2: value2");
7+
8+
const options = mockupParser.getOptions(el, "testpattern");
9+
1110
expect(options.option1).toBe("value1");
1211
expect(options.option2).toBe("value2");
1312
});
13+
1414
it("parses the data attribute of nested nodes", function () {
15-
const $el = $(`
16-
<div data-pat-testpattern="parentOption1: value1; parentOption2: value2">
17-
<span class="pat-testpattern" data-pat-testpattern="option1: subvalue1; option2: subvalue2">
18-
nested mockup parser test
19-
</span>
20-
</div>`);
21-
const options = mockupParser.getOptions($(".pat-testpattern", $el), "testpattern");
15+
const el = document.createElement("div");
16+
el.setAttribute(
17+
"data-pat-testpattern",
18+
"parentOption1: value1; parentOption2: value2"
19+
);
20+
const el2 = document.createElement("span");
21+
el2.setAttribute(
22+
"data-pat-testpattern",
23+
"option1: subvalue1; option2: subvalue2"
24+
);
25+
el.appendChild(el2);
26+
27+
const options = mockupParser.getOptions(el2, "testpattern");
28+
2229
expect(options.parentOption1).toBe("value1");
2330
expect(options.parentOption2).toBe("value2");
2431
expect(options.option1).toBe("subvalue1");
2532
expect(options.option2).toBe("subvalue2");
2633
});
34+
2735
it("parses the data attribute of a single node and preserves injected options", function () {
28-
const $el = $(`
29-
<span data-pat-testpattern="option1: value1; option2: value2">
30-
mockup parser test
31-
</span>
32-
`);
33-
const options = mockupParser.getOptions($el, "testpattern", {
36+
const el = document.createElement("div");
37+
el.setAttribute("data-pat-testpattern", "option1: value1; option2: value2");
38+
39+
const options = mockupParser.getOptions(el, "testpattern", {
3440
injectedOption: "injectedValue",
3541
});
42+
3643
expect(options.option1).toBe("value1");
3744
expect(options.option2).toBe("value2");
3845
expect(options.injectedOption).toBe("injectedValue");

0 commit comments

Comments
 (0)