Page Menu
Home
Sealhub
Search
Configure Global Search
Log In
Files
F1262653
stateful-page.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
stateful-page.test.ts
View Options
import
{
Context
}
from
"koa"
;
import
{
Templatable
,
tempstream
}
from
"tempstream"
;
import
{
ExtractStatefulPageActionArgs
,
StatefulPage
,
StatefulPageActionArgument
,
}
from
"./stateful-page.js"
;
describe
(
"stateful page"
,
()
=>
{
it
(
"has types that allow for extracting action argument types"
,
()
=>
{
type
TestState
=
{};
const
action
=
async
({}
:
StatefulPageActionArgument
<
TestState
,
[
number
]
>
)
=>
{};
type
Args
=
ExtractStatefulPageActionArgs
<
typeof
action
>
;
const
a
=
[
2
]
as
Args
;
// should not throw a typescript error;
});
it
(
"handles a basic case with action buttons"
,
()
=>
{
type
TestState
=
{};
const
actions
=
<
const
>
{
some_action
:
async
({}
:
StatefulPageActionArgument
<
TestState
,
[
number
]
>
)
=>
{},
};
new
(
class
extends
StatefulPage
<
TestState
,
typeof
actions
>
{
actions
=
actions
;
getInitialState
(
_ctx
:
Context
)
{
return
{};
}
wrapInLayout
(
_ctx
:
Context
,
content
:
Templatable
,
_state
:
TestState
)
:
Templatable
{
return
content
;
}
render
(
_ctx
:
Context
,
state
:
TestState
)
{
return
tempstream
`<div>
${
this
.
makeActionButton
(
state
,
"some_action"
,
2
)
}
</div>`
;
}
})();
});
});
File Metadata
Details
Attached
Mime Type
text/x-java
Expires
Fri, Jan 24, 15:15 (1 d, 8 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
599851
Default Alt Text
stateful-page.test.ts (1 KB)
Attached To
Mode
rSGEN sealgen
Attached
Detach File
Event Timeline
Log In to Comment