Page Menu
Home
Sealhub
Search
Configure Global Search
Log In
Files
F996362
component.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
component.test.ts
View Options
import
assert
from
"assert"
;
import
{
Table
}
from
"./component-arguments/table.js"
;
import
{
Component
}
from
"./component.js"
;
import
{
List
,
ShortText
,
Structured
,
makeSimpleEnglishJDDContext
,
makeSimpleJDDContext
,
}
from
"./index.js"
;
import
{
FileManager
}
from
"@sealcode/file-manager"
;
describe
(
"component class"
,
()
=>
{
describe
(
"getSubArgument"
,
()
=>
{
it
(
"traverses argument path that includes a table"
,
()
=>
{
const
args
=
{
table
:
new
Table
(
new
Structured
({
title
:
new
ShortText
()
}),
new
Structured
({
tags
:
new
List
(
new
ShortText
())
})
),
};
const
component
=
new
(
class
extends
Component
<
typeof
args
>
{
getArguments
()
{
return
args
;
}
toHTML
()
{
return
""
;
}
})();
const
[
arg
,
_
,
values
]
=
component
.
getArgumentAtPath
(
"table/rows/2/cells/0/tags"
.
split
(
"/"
),
{
table
:
{
rows
:
[
{
type
:
"header"
,
header_content
:
{
title
:
"hehe"
},
},
{
type
:
"header"
,
header_content
:
{
title
:
"hehe2"
},
},
{
type
:
"row"
,
cells
:
[{
tags
:
[
"tag1"
,
"tag2"
]
}],
},
],
},
}
);
assert
(
arg
instanceof
List
);
assert
.
deepStrictEqual
(
values
,
[
"tag1"
,
"tag2"
]);
});
});
it
(
"Doesn't fail if provided with unknown arguments"
,
async
()
=>
{
const
args
=
{
title
:
new
ShortText
(),
};
const
component
=
new
(
class
extends
Component
<
typeof
args
>
{
getArguments
()
{
return
args
;
}
toHTML
()
{
return
""
;
}
})();
await
component
.
convertStorageToParsed
(
makeSimpleEnglishJDDContext
(
new
FileManager
(
"/tmp"
,
"/tmp"
)),
{
title2
:
"string"
}
as
any
);
await
component
.
convertParsedToStorage
(
makeSimpleEnglishJDDContext
(
new
FileManager
(
"/tmp"
,
"/tmp"
)),
{
title2
:
"string"
}
as
any
);
});
});
File Metadata
Details
Attached
Mime Type
text/x-java
Expires
Tue, Dec 24, 14:02 (17 h, 30 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
557208
Default Alt Text
component.test.ts (1 KB)
Attached To
Mode
R130 jdd
Attached
Detach File
Event Timeline
Log In to Comment