Page Menu
Home
Sealhub
Search
Configure Global Search
Log In
Files
F996621
field.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
field.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
{
Form
}
from
"../form.js"
;
import
{
getBrowser
}
from
"../../utils/browser-creator.js"
;
import
assert
from
"assert"
;
import
{
SimpleFormField
}
from
"./simple-form-field.js"
;
import
{
SimpleInput
}
from
"../controls/simple-input.js"
;
import
{
FormData
}
from
"../form-types.js"
;
describe
(
"basic field"
,
()
=>
{
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
=
{
text
:
new
SimpleFormField
(
true
),
};
let
received_values
:
unknown
;
mount
(
router
,
"/"
,
new
(
class
extends
Form
<
typeof
fields
,
unknown
>
{
fields
=
fields
;
controls
=
[
new
SimpleInput
(
fields
.
text
)];
async
onSubmit
(
ctx
:
Context
,
data
:
FormData
)
{
received_values
=
await
this
.
getParsedValues
(
ctx
);
const
{
parsed
:
email
}
=
await
this
.
fields
.
text
.
getValue
(
ctx
,
data
.
raw_values
);
email
?
.
padStart
(
2
,
"0"
);
// if the typechecks are ok, this will not throw
}
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
}
`
);
});
});
});
File Metadata
Details
Attached
Mime Type
text/x-java
Expires
Tue, Dec 24, 14:06 (10 m, 34 s)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
557345
Default Alt Text
field.test.ts (1 KB)
Attached To
Mode
rSGEN sealgen
Attached
Detach File
Event Timeline
Log In to Comment