Page Menu
Home
Sealhub
Search
Configure Global Search
Log In
Files
F1262966
structured.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
structured.test.ts
View Options
import
{
FileManager
}
from
"@sealcode/file-manager"
;
import
{
makeSimpleEnglishJDDContext
}
from
"../jdd-context.js"
;
import
{
ExtractParsed
}
from
"./component-argument.js"
;
import
{
List
}
from
"./list.js"
;
import
{
ShortText
}
from
"./short-text.js"
;
import
{
Structured
}
from
"./structured.js"
;
import
assert
from
"assert"
;
describe
(
"structured argument"
,
()
=>
{
it
(
"properly extracts parsed type"
,
()
=>
{
const
args
=
new
Structured
({
value
:
new
ShortText
().
setExampleValues
([
""
]),
tags
:
new
List
(
new
ShortText
()).
setExampleValues
([[
"okazja"
]]),
});
const
values
=
{
value
:
"test"
,
tags
:
[
"tag1"
,
"tag2"
],
}
as
ExtractParsed
<
typeof
args
>
;
values
.
tags
.
map
((
tag
)
=>
tag
.
padStart
(
10
));
// if the types are OK, this will typecheck OK
});
it
(
"properly extracts parsed type within a list"
,
()
=>
{
const
arg
=
new
List
(
new
Structured
({
value
:
new
ShortText
().
setExampleValues
([
""
]),
tags
:
new
List
(
new
ShortText
()).
setExampleValues
([[
"okazja"
]]),
})
);
const
values
=
[
{
value
:
"test"
,
tags
:
[
"tag1"
,
"tag2"
],
},
]
as
ExtractParsed
<
typeof
arg
>
;
values
[
0
].
tags
.
map
((
tag
)
=>
tag
.
padStart
(
10
));
// if the types are OK, this will typecheck OK
});
it
(
"uses the provided object as an example value if set"
,
async
()
=>
{
const
arg
=
new
Structured
({
value
:
new
ShortText
().
setExampleValues
([
""
]),
tags
:
new
List
(
new
ShortText
()).
setExampleValues
([[
"okazja"
]]),
}).
setExampleValues
([{
value
:
"override"
,
tags
:
[
"override"
]
}]);
const
example_value
=
await
arg
.
getExampleValue
(
makeSimpleEnglishJDDContext
(
new
FileManager
(
"/tmp"
,
"/uploaded_files"
)
)
);
assert
.
deepStrictEqual
(
example_value
,
{
value
:
"override"
,
tags
:
[
"override"
],
});
});
});
File Metadata
Details
Attached
Mime Type
text/x-java
Expires
Fri, Jan 24, 15:16 (17 h, 21 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
601028
Default Alt Text
structured.test.ts (1 KB)
Attached To
Mode
rJDD jdd
Attached
Detach File
Event Timeline
Log In to Comment