Page Menu
Home
Sealhub
Search
Configure Global Search
Log In
Files
F3010644
checkboxed-list-input.test.ts
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
1 KB
Referenced Files
None
Subscribers
None
checkboxed-list-input.test.ts
View Options
import
Router
from
"@koa/router"
;
import
getPort
from
"get-port"
;
import
{
Browser
,
Page
}
from
"playwright"
;
import
type
{
Context
}
from
"koa"
;
import
Koa
from
"koa"
;
import
{
mount
}
from
"../../mount.js"
;
import
{
CheckboxedListField
}
from
"../fields/checkboxed-list.js"
;
import
{
Form
}
from
"../form.js"
;
import
{
CheckboxedListInput
}
from
"./checkboxed-list-input.js"
;
import
{
getBrowser
}
from
"../../utils/browser-creator.js"
;
import
assert
from
"assert"
;
describe
(
"checkboxed-list"
,
()
=>
{
describe
(
"basic tests"
,
async
()
=>
{
let
server
:
ReturnType
<
Koa
[
"listen"
]
>
;
let
browser
:
Browser
;
let
page
:
Page
;
afterEach
(()
=>
{
server
.
close
();
});
it
(
"sends the values"
,
async
()
=>
{
const
port
=
await
getPort
();
console
.
log
(
`Using port
${
port
}
form checkboxed-list-input.test.ts`
);
const
app
=
new
Koa
();
const
router
=
new
Router
();
const
fields
=
{
syllables
:
new
CheckboxedListField
(
true
,
async
()
=>
{
return
[
"sa"
,
"mple"
,
"co"
,
"de"
].
map
((
s
)
=>
({
value
:
s
,
label
:
s
.
toLocaleUpperCase
(),
}));
}),
};
let
received_values
:
unknown
;
mount
(
router
,
"/"
,
new
(
class
extends
Form
<
typeof
fields
,
unknown
>
{
fields
=
fields
;
controls
=
[
new
CheckboxedListInput
(
fields
.
syllables
)];
async
onSubmit
(
ctx
:
Context
)
{
received_values
=
await
this
.
getParsedValues
(
ctx
);
}
async
canAccess
(
_
:
Context
)
{
return
{
canAccess
:
true
,
message
:
""
};
}
})(),
true
);
app
.
use
(
router
.
routes
()).
use
(
router
.
allowedMethods
());
server
=
app
.
listen
(
port
);
browser
=
await
getBrowser
();
const
context
=
await
browser
.
newContext
();
page
=
await
context
.
newPage
();
await
page
.
goto
(
`http://localhost:
${
port
}
`
);
await
page
.
getByLabel
(
"CO"
).
check
();
await
page
.
getByLabel
(
"DE"
).
check
();
await
page
.
getByRole
(
"button"
,
{
name
:
"Wyślij"
}).
click
();
assert
.
deepStrictEqual
(
received_values
,
{
syllables
:
{
co
:
"on"
,
de
:
"on"
}
});
});
});
});
File Metadata
Details
Attached
Mime Type
text/x-java
Expires
Wed, May 7, 19:45 (1 d, 4 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
661827
Default Alt Text
checkboxed-list-input.test.ts (1 KB)
Attached To
Mode
rSGEN sealgen
Attached
Detach File
Event Timeline
Log In to Comment