forked from surveyjs/survey-library
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhtmlQuestion.js
61 lines (54 loc) · 1.66 KB
/
htmlQuestion.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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
import {
frameworks,
url,
setOptions,
initSurvey,
getSurveyResult
} from "../settings";
import { Selector, ClientFunction } from "testcafe";
const assert = require("assert");
const title = `html`;
const json = {
questions: [
{
type: "html",
name: "info",
html:
"<table><body><row><td><img src='https://surveyjs.io/Content/Images/examples/26178-20160417.jpg' width='100px' /></td><td style='padding:20px'>You may put here any html code. For example images, <b>text</b> or <a href='https://surveyjs.io/Editor/Editor/' target='_blank'>links</a></td></row></body></table>"
}
]
};
frameworks.forEach(framework => {
fixture`${framework} ${title}`.page`${url}${framework}`.beforeEach(
async t => {
await initSurvey(framework, json);
}
);
test(`check html elements`, async t => {
const getImageExistance = ClientFunction(
() =>
!!document.querySelector(
'table img[src="https://surveyjs.io/Content/Images/examples/26178-20160417.jpg"]'
)
);
const getBoldExistance = ClientFunction(
() => !!document.querySelector("table b")
);
const getLinkExistance = ClientFunction(
() =>
!!document.querySelector(
'table a[href="https://surveyjs.io/Editor/Editor/"]'
)
);
assert(await getImageExistance());
assert(await getBoldExistance());
assert(await getLinkExistance());
});
test(`change html`, async t => {
const getPosition = ClientFunction(() =>
document.documentElement.innerHTML.indexOf("Wombat")
);
await setOptions("info", { html: "<h1>Wombat</h1>" });
assert.notEqual(await getPosition(), -1);
});
});