Page Menu
Home
Sealhub
Search
Configure Global Search
Log In
Files
F7188035
document.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
document.test.ts
View Options
import
{
FileManager
}
from
"@sealcode/file-manager"
;
import
{
Component
,
ComponentArgument
,
JDDContext
,
documentContainerFromParsed
,
documentToStorage
,
makeSimpleJDDContext
,
}
from
"./index.js"
;
import
{
Registry
}
from
"./registry.js"
;
import
assert
from
"assert"
;
describe
(
"document"
,
()
=>
{
it
(
"converts from parsed to storage"
,
async
()
=>
{
const
registry
=
new
Registry
();
const
args
=
{
test
:
new
(
class
extends
ComponentArgument
<
number
,
string
,
string
>
{
countWords
()
{
return
0
;
}
getEmptyValue
()
{
return
0
;
}
getSubArgument
()
:
never
{
throw
new
Error
(
"no arguments"
);
}
getTypeName
()
{
return
"test"
;
}
async
storageToParsed
(
_context
:
JDDContext
,
value
:
string
)
:
Promise
<
number
>
{
return
parseInt
(
value
);
}
async
parsedToStorage
(
_context
:
JDDContext
,
value
:
number
)
:
Promise
<
string
>
{
return
value
.
toString
();
}
async
receivedToParsed
(
_context
:
JDDContext
,
value
:
string
)
:
Promise
<
number
>
{
return
parseInt
(
value
);
}
})(),
};
registry
.
add
(
"test"
,
class
extends
Component
<
typeof
args
>
{
getArguments
()
{
return
args
;
}
toHTML
()
{
return
""
;
}
}
);
const
document
=
documentContainerFromParsed
([
{
component_name
:
"test"
,
args
:
{
test
:
1
}
},
{
component_name
:
"test"
,
args
:
{
test
:
2
}
},
]);
const
to_store
=
await
documentToStorage
(
registry
,
makeSimpleJDDContext
(
new
FileManager
(
"/tmp"
,
"/uploaded_files"
)),
document
);
assert
.
deepStrictEqual
(
to_store
.
value
,
[
{
component_name
:
"test"
,
args
:
{
test
:
"1"
}
},
{
component_name
:
"test"
,
args
:
{
test
:
"2"
}
},
]);
});
});
File Metadata
Details
Attached
Mime Type
text/x-java
Expires
Tue, Jul 8, 07:50 (17 h, 55 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
801597
Default Alt Text
document.test.ts (1 KB)
Attached To
Mode
rJDD jdd
Attached
Detach File
Event Timeline
Log In to Comment