mirror of
https://github.com/idrawjs/idraw
synced 2026-05-24 10:08:34 +00:00
feat: update core.check.circleDesc
This commit is contained in:
parent
417f2fa98c
commit
f7953be78a
2 changed files with 42 additions and 0 deletions
|
|
@ -55,6 +55,30 @@ describe("@idraw/core static check", () => {
|
|||
});
|
||||
|
||||
|
||||
test('Core.check.circleDesc', () => {
|
||||
|
||||
expect(Core.check.circleDesc({
|
||||
color: '#ffffff',
|
||||
})).toStrictEqual(true);
|
||||
|
||||
expect(Core.check.circleDesc({
|
||||
color: 123,
|
||||
})).toStrictEqual(false);
|
||||
|
||||
expect(Core.check.circleDesc({
|
||||
borderWidth: 10,
|
||||
borderColor: '#123abf',
|
||||
color: '#ffffff',
|
||||
})).toStrictEqual(true);
|
||||
|
||||
expect(Core.check.circleDesc({
|
||||
borderWidth: 10,
|
||||
borderColor: '#123af',
|
||||
})).toStrictEqual(false);
|
||||
|
||||
});
|
||||
|
||||
|
||||
test('Core.check.imageDesc', () => {
|
||||
|
||||
expect(Core.check.imageDesc({
|
||||
|
|
|
|||
|
|
@ -45,6 +45,22 @@ function rectDesc(
|
|||
return true;
|
||||
}
|
||||
|
||||
function circleDesc(
|
||||
desc: any
|
||||
): boolean {
|
||||
const { color, borderColor, borderWidth } = desc;
|
||||
if (desc.hasOwnProperty('color') && !is.color(color)) {
|
||||
return false;
|
||||
}
|
||||
if (desc.hasOwnProperty('borderColor') && !is.color(borderColor)) {
|
||||
return false;
|
||||
}
|
||||
if (desc.hasOwnProperty('borderWidth') && !is.number(borderWidth)) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
function imageDesc(
|
||||
desc: any
|
||||
|
|
@ -106,6 +122,7 @@ function textDesc(
|
|||
const check = {
|
||||
attrs,
|
||||
rectDesc,
|
||||
circleDesc,
|
||||
imageDesc,
|
||||
svgDesc,
|
||||
textDesc,
|
||||
|
|
@ -114,6 +131,7 @@ const check = {
|
|||
type TypeCheck = {
|
||||
attrs: (value: any) => boolean,
|
||||
rectDesc: (value: any) => boolean,
|
||||
circleDesc: (value: any) => boolean,
|
||||
imageDesc: (value: any) => boolean,
|
||||
svgDesc: (value: any) => boolean,
|
||||
textDesc: (value: any) => boolean,
|
||||
|
|
|
|||
Loading…
Reference in a new issue