Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
bonita
bonita-ui-designer-sdk
Commits
bae3f104
Commit
bae3f104
authored
Nov 25, 2021
by
benjaminParisel
Browse files
adding test for allow-html fix
* make some properties key optional
parent
e259f02a
Changes
2
Hide whitespace changes
Inline
Side-by-side
custom-widget-builder/src/Property.ts
View file @
bae3f104
...
...
@@ -24,12 +24,12 @@ export interface Property {
name
:
string
;
type
:
PropertyType
|
undefined
;
label
:
string
|
undefined
;
help
:
string
|
undefined
;
help
?
:
string
|
undefined
;
defaultValue
:
string
|
number
|
boolean
|
undefined
;
constraints
:
PropertyConstraint
|
undefined
;
showFor
:
string
|
undefined
;
constraints
?
:
PropertyConstraint
|
undefined
;
showFor
?
:
string
|
undefined
;
bond
:
Bond
|
undefined
;
choiceValues
:
Array
<
string
>
|
undefined
;
caption
:
string
|
undefined
;
choiceValues
?
:
Array
<
string
>
|
undefined
;
caption
?
:
string
|
undefined
;
}
custom-widget-builder/test/HtmlTemplateGenerator.test.ts
View file @
bae3f104
...
...
@@ -17,9 +17,12 @@
*/
import
{
CustomWidgetBuilder
}
from
"
../src/CustomWidgetBuilder
"
;
import
{
HtmlTemplatesGenerator
}
from
"
../src/HtmlTemplatesGenerator
"
;
import
{
FwkType
,
HtmlTemplatesGenerator
}
from
"
../src/HtmlTemplatesGenerator
"
;
import
*
as
os
from
"
os
"
;
import
{
sep
}
from
"
path
"
;
import
{
PropertiesInfo
}
from
"
../src/PropertiesInfo
"
;
import
{
PropertyType
}
from
"
../src/PropertyType
"
;
import
{
Bond
}
from
"
../src/Bond
"
;
const
fs
=
require
(
'
fs
'
);
...
...
@@ -103,6 +106,55 @@ describe('HtmlTemplateGenerator', () => {
checkStringContains
(
templateAngular
,
expectedPropsAngular
);
}
test
(
'
should generate html attributes name in camelCase
'
,
function
(){
let
propertiesInfos
:
PropertiesInfo
=
{
"
id
"
:
"
myInput
"
,
"
name
"
:
"
MyInput
"
,
"
type
"
:
"
widget
"
,
"
template
"
:
"
@myInput.tpl.html
"
,
"
description
"
:
"
Field where the user can enter information
"
,
"
order
"
:
"
1
"
,
"
custom
"
:
true
,
"
modelVersion
"
:
"
3.0
"
,
"
icon
"
:
""
,
"
jsBundle
"
:
""
,
"
htmlBundle
"
:
""
,
"
properties
"
:
[
{
"
label
"
:
"
Interpret HTML
"
,
"
name
"
:
"
allowHTML
"
,
"
help
"
:
"
If you choose 'no', HTML code will be escaped instead of being interpreted
"
,
"
type
"
:
PropertyType
.
Boolean
,
"
defaultValue
"
:
false
,
"
bond
"
:
Bond
.
Constant
},
{
"
label
"
:
"
Label position
"
,
"
name
"
:
"
labelPosition
"
,
"
type
"
:
PropertyType
.
Choice
,
"
choiceValues
"
:
[
"
left
"
,
"
top
"
],
"
defaultValue
"
:
"
top
"
,
"
bond
"
:
Bond
.
Constant
,
"
showFor
"
:
"
properties.labelHidden.value === false
"
}
],
"
assets
"
:[]
};
let
html
=
new
HtmlTemplatesGenerator
(
propertiesInfos
);
expect
(
html
[
'
generateProperties
'
](
FwkType
.
Angular
)).
toContain
(
"
labelPosition=
\"
{{properties.labelPosition}}
\"
"
);
let
booleanProperties
=
html
[
'
generateIfBoolean
'
](
FwkType
.
Angular
);
expect
(
booleanProperties
.
length
).
toEqual
(
2
);
expect
(
booleanProperties
[
1
]).
toBe
(
'
*ngIf="properties.allowHTML"
\n
'
+
'
\t
allow-html
\n
'
+
'
\t
'
);
});
function
checkStringContains
(
str
:
string
,
items
:
Array
<
string
>
)
{
for
(
let
item
of
items
)
{
expect
(
str
.
includes
(
item
)).
toBeTruthy
();
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment