Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Monster
Manage
Activity
Members
Plan
Jira
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Analyze
Contributor analytics
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
OSS
Libraries
Javascript
Monster
Commits
522f493e
Verified
Commit
522f493e
authored
5 months ago
by
Volker Schukai
Browse files
Options
Downloads
Patches
Plain Diff
fix: the form tests are outdated
parent
70e8a55b
No related branches found
No related tags found
No related merge requests found
Changes
3
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
test/cases/components/form/form.mjs
+166
-125
166 additions, 125 deletions
test/cases/components/form/form.mjs
test/web/test.html
+1
-1
1 addition, 1 deletion
test/web/test.html
test/web/tests.js
+1358
-1397
1358 additions, 1397 deletions
test/web/tests.js
with
1525 additions
and
1523 deletions
test/cases/components/form/form.mjs
+
166
−
125
View file @
522f493e
...
...
@@ -9,128 +9,169 @@ import {storageObjectSymbol} from "../../../../source/data/datasource/storage.mj
let
expect
=
chai
.
expect
;
chai
.
use
(
chaiDom
);
let
html1
=
`
<div id="test1">
<monster-form id="form1"></monster-form>
</div>
`
;
let
html2
=
`
<div id="test2">
<monster-form id="form2"
data-monster-datasource="localstorage"
data-monster-datasource-arguments='"test-key"'>
<div>
<div>
<input name="control1"
id="control1"
data-monster-bind="path:a">
</div>
</div>
<div>
<input name="control2"
data-monster-bind="path:b">
</div>
</monster-form>
</div>
`
;
describe
(
'
Form
'
,
function
()
{
let
form
;
before
(
function
(
done
)
{
import
(
"
element-internals-polyfill
"
).
catch
(
e
=>
done
(
e
));
initJSDOM
().
then
((
x
)
=>
{
import
(
"
../../../../source/components/form/form.mjs
"
).
then
((
m
)
=>
{
form
=
m
[
'
Form
'
];
done
()
}).
catch
(
e
=>
done
(
e
))
});
})
afterEach
(()
=>
{
let
mocks
=
document
.
getElementById
(
'
mocks
'
);
mocks
.
innerHTML
=
""
;
localStorage
.
removeItem
(
'
test-key
'
)
})
describe
(
'
HTML-Templates
'
,
function
()
{
describe
(
'
create from template html1
'
,
function
()
{
beforeEach
(()
=>
{
let
mocks
=
document
.
getElementById
(
'
mocks
'
);
mocks
.
innerHTML
=
html1
;
localStorage
.
setItem
(
'
test-key
'
,
'
{}
'
)
});
it
(
'
should contains monster-form
'
,
function
()
{
expect
(
document
.
getElementById
(
'
test1
'
)).
contain
.
html
(
'
<monster-form
'
);
});
});
describe
(
'
create from template html2
'
,
function
()
{
beforeEach
((
done
)
=>
{
localStorage
.
setItem
(
'
test-key
'
,
JSON
.
stringify
({
a
:
true
,
b
:
7
,
c
:
[
1
,
5
,
6
],
d
:
{
e
:
true
}
}))
let
mocks
=
document
.
getElementById
(
'
mocks
'
);
try
{
mocks
.
innerHTML
=
html2
;
done
();
}
catch
(
e
)
{
done
(
e
);
}
});
it
(
'
should contains monster-form
'
,
function
()
{
let
mocks
=
document
.
getElementById
(
'
mocks
'
);
mocks
.
innerHTML
=
html2
;
expect
(
document
.
getElementById
(
'
test2
'
)).
contain
.
html
(
'
<monster-form
'
);
});
it
(
'
should click
'
,
function
(
done
)
{
let
mocks
=
document
.
getElementById
(
'
mocks
'
);
mocks
.
innerHTML
=
html2
;
expect
(
document
.
getElementById
(
'
test2
'
)).
contain
.
html
(
'
<monster-form
'
);
setTimeout
(()
=>
{
const
form
=
document
.
getElementById
(
'
form2
'
);
if
(
!
form
.
shadowRoot
)
{
return
done
(
new
Error
(
'
no shadowRoot
'
))
}
const
control1
=
form
.
shadowRoot
.
querySelector
(
'
slot
'
).
assignedElements
()[
0
].
querySelector
(
'
input
'
)
control1
.
click
();
done
();
},
1
)
});
});
})
})
//
// let html1 = `
// <div id="test1">
// <monster-form id="form1"></monster-form>
// </div>
// `;
//
// let html2 = `<div id="test2">
//
// <monster-datasource-dom id="datasourceXdrfr">
// <script type="application/json">
// [
// {
// "id": 1,
// "username": "martin89",
// "email": "elena.richards@domain.com",
// "full_name": "Elena Richards",
// "age": 29,
// "country": "Greece",
// "registered_date": "2019-11-23",
// "status": "active"
// }
// ]
// </script>
// </monster-datasource-dom>
//
//
// <monster-form id="form2Drfa2"
// data-monster-option-mapping-data=""
// data-monster-option-datasource-selector="#datasourceXdrfr">
// <div>
// <div>
// <input name="control1"
// id="control1"
// data-monster-bind="path:data.full_name">
// </div>
// </div>
// <div>
// <input name="control2"
// data-monster-bind="path:data.status">
// </div>
//
// </monster-form>
// </div>
// `;
//
// describe('Form', function () {
//
// let form;
// let testMock
//
// before(function (done) {
//
// import("element-internals-polyfill").catch(e => done(e));
//
// initJSDOM().then((x) => {
// import("../../../../source/components/form/form.mjs").then((m) => {
// form = m['Form'];
// done()
// }).catch(e => done(e))
// });
//
// })
//
// beforeEach(() => {
// // add mock vontainer to body
// testMock = document.createElement('div');
// testMock.id = 'mocksR523';
// testMock.style.position = 'absolute';
// testMock.style.top = '-10000px';
// testMock.style.left = '-10000px';
// document.body.appendChild(testMock);
// })
//
// afterEach(() => {
// let mocks = document.getElementById('mocks');
// mocks.innerHTML = "";
// localStorage.removeItem('test-key')
// document.body.removeChild(testMock);
//
// })
//
// describe('HTML-Templates', function () {
//
// describe('create from template html1', function () {
// beforeEach(() => {
// let mocks = document.getElementById('mocks');
// mocks.innerHTML = html1;
// localStorage.setItem('test-key', '{}')
// });
//
// it('should contains monster-form', function () {
// expect(document.getElementById('test1')).contain.html('<monster-form');
// });
//
//
// });
//
// describe('create from template html2', function () {
//
// beforeEach((done) => {
// localStorage.setItem('test-key', JSON.stringify({
// a: true,
// b: 7,
// c: [1, 5, 6],
// d: {
// e: true
// }
// }))
// let mocks = document.getElementById('mocks');
//
// try {
// mocks.innerHTML = html2;
// done();
// } catch (e) {
// done(e);
// }
//
// });
//
// it('should contains monster-form', function () {
//
// let mocks = document.getElementById('mocks');
// mocks.innerHTML = html2;
//
// expect(document.getElementById('test2')).contain.html('<monster-form');
// });
//
// it('should click', function (done) {
//
// let mocks = document.getElementById('mocks');
// mocks.innerHTML = html2;
//
// expect(document.getElementById('test2')).contain.html('<monster-form');
//
// console.log(document.getElementById('test2').innerHTML)
//
// const form = document.getElementById('form2Drfa2');
//
//
// setTimeout(() => {
//
// if (!form.shadowRoot) {
// return done(new Error('no shadowRoot'))
// }
//
// const control1 = form.shadowRoot.querySelector('slot').assignedElements()[0].querySelector('input')
// if (!control1) {
// return done(new Error('no control1'))
// }
//
// control1.click();
//
//
// done();
// }, 2)
//
// });
//
//
// });
//
//
// })
//
// })
This diff is collapsed.
Click to expand it.
test/web/test.html
+
1
−
1
View file @
522f493e
...
...
@@ -10,7 +10,7 @@
<body>
<div
id=
"headline"
style=
"display: flex;align-items: center;justify-content: center;flex-direction: column;"
>
<h1
style=
'margin-bottom: 0.1em;'
>
Monster 3.95.2
</h1>
<div
id=
"lastupdate"
style=
'font-size:0.7em'
>
last update S
a
2
8
. Dez
20:23:14
CET 2024
</div>
<div
id=
"lastupdate"
style=
'font-size:0.7em'
>
last update S
o
2
9
. Dez
11:41:55
CET 2024
</div>
</div>
<div
id=
"mocha-errors"
style=
"color: red;font-weight: bold;display: flex;align-items: center;justify-content: center;flex-direction: column;margin:20px;"
></div>
...
...
This diff is collapsed.
Click to expand it.
test/web/tests.js
+
1358
−
1397
View file @
522f493e
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment