-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPATTERN_TEMPLATE.test.js
34 lines (28 loc) · 1.21 KB
/
PATTERN_TEMPLATE.test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import Pattern from "./PATTERN_TEMPLATE";
import events from "@patternslib/patternslib/src/core/events";
describe("pat-PATTERN_TEMPLATE", function () {
afterEach(function () {
document.body.innerHTML = "";
});
it("is initialized correctly", async function () {
document.body.innerHTML = `<div class="pat-PATTERN_TEMPLATE" />`;
const el = document.querySelector(".pat-PATTERN_TEMPLATE");
const instance = new Pattern(el);
await events.await_pattern_init(instance);
expect(el.innerHTML.trim()).toBe(
`<p>hello ${instance.options.exampleOption}, this is pattern ${instance.name} speaking.</p>`
);
});
it("is initialized correctly with options from attribute", async function () {
document.body.innerHTML = `<div
class="pat-PATTERN_TEMPLATE"
data-pat-PATTERN_TEMPLATE='{"example-option": "World"}'
/>`;
const el = document.querySelector(".pat-PATTERN_TEMPLATE");
const instance = new Pattern(el);
await events.await_pattern_init(instance);
expect(el.innerHTML.trim()).toBe(
`<p>hello World, this is pattern ${instance.name} speaking.</p>`
);
});
});