mirror of
https://github.com/idrawjs/idraw
synced 2026-05-24 10:08:34 +00:00
feat: add core.check.htmlDesc
This commit is contained in:
parent
f7953be78a
commit
042e34afca
2 changed files with 38 additions and 1 deletions
|
|
@ -133,6 +133,31 @@ describe("@idraw/core static check", () => {
|
|||
});
|
||||
|
||||
|
||||
test('Core.check.htmlDesc', () => {
|
||||
expect(Core.check.htmlDesc({
|
||||
html: `
|
||||
<style>
|
||||
.box { display: block }
|
||||
</style>
|
||||
<div class="box">Hello World</div>
|
||||
`,
|
||||
})).toStrictEqual(true);
|
||||
|
||||
expect(Core.check.htmlDesc({
|
||||
html: `
|
||||
abcdefg
|
||||
<div class="box">Hello World</div>
|
||||
`,
|
||||
})).toStrictEqual(true);
|
||||
|
||||
expect(Core.check.htmlDesc({
|
||||
html: 'Hello World',
|
||||
})).toStrictEqual(false);
|
||||
|
||||
expect(Core.check.htmlDesc({})).toStrictEqual(false);
|
||||
});
|
||||
|
||||
|
||||
test('Core.check.textDesc', () => {
|
||||
expect(Core.check.textDesc({
|
||||
text: 'abcdefg',
|
||||
|
|
|
|||
|
|
@ -82,6 +82,16 @@ function svgDesc(
|
|||
return true;
|
||||
}
|
||||
|
||||
function htmlDesc(
|
||||
desc: any
|
||||
): boolean {
|
||||
const { html } = desc;
|
||||
if (!is.html(html)) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
function textDesc(
|
||||
desc: any
|
||||
): boolean {
|
||||
|
|
@ -121,11 +131,12 @@ function textDesc(
|
|||
|
||||
const check = {
|
||||
attrs,
|
||||
textDesc,
|
||||
rectDesc,
|
||||
circleDesc,
|
||||
imageDesc,
|
||||
svgDesc,
|
||||
textDesc,
|
||||
htmlDesc,
|
||||
};
|
||||
|
||||
type TypeCheck = {
|
||||
|
|
@ -134,6 +145,7 @@ type TypeCheck = {
|
|||
circleDesc: (value: any) => boolean,
|
||||
imageDesc: (value: any) => boolean,
|
||||
svgDesc: (value: any) => boolean,
|
||||
htmlDesc: (value: any) => boolean,
|
||||
textDesc: (value: any) => boolean,
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue