Page Menu
Home
Sealhub
Search
Configure Global Search
Log In
Files
F969975
collection-subject.test.js
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
1 KB
Referenced Files
None
Subscribers
None
collection-subject.test.js
View Options
const
locreq
=
require
(
"locreq"
)(
__dirname
);
const
assert
=
require
(
"assert"
);
const
sinon
=
require
(
"sinon"
);
const
{
with_stopped_app
}
=
locreq
(
"test_utils/with-test-app.js"
);
describe
(
"collection-subject"
,
()
=>
{
describe
(
"multiple post"
,
()
=>
{
it
(
"should fire handlers for every resource"
,
async
()
=>
with_stopped_app
(
async
({
app
,
rest_api
})
=>
{
app
.
createChip
(
app
.
Sealious
.
Collection
,
{
name
:
"target"
,
fields
:
[{
name
:
"value"
,
type
:
"int"
}],
});
app
.
createChip
(
app
.
Sealious
.
Collection
,
{
name
:
"source"
,
fields
:
[{
name
:
"value"
,
type
:
"int"
}],
});
const
handler
=
sinon
.
spy
();
app
.
addHook
(
new
app
.
Sealious
.
EventMatchers
.
Collection
({
when
:
"after"
,
collection_name
:
"target"
,
action
:
"create"
,
}),
handler
);
await
app
.
start
();
for
(
let
i
=
1
;
i
<=
3
;
i
++
)
{
await
rest_api
.
post
(
"/api/v1/collections/source"
,
{
value
:
i
,
});
}
await
rest_api
.
post
(
"/api/v1/collections/target"
,
{
__multiple
:
true
,
mode
:
"cartesian"
,
sources
:
[
[
"collection_fields"
,
{
collection
:
"source"
,
filter
:
{},
fields
:
[
"value"
],
map_to
:
[
"value"
],
},
],
],
});
assert
.
equal
(
handler
.
callCount
,
4
);
}));
});
});
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sun, Nov 24, 03:25 (20 h, 38 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
548143
Default Alt Text
collection-subject.test.js (1 KB)
Attached To
Mode
rS Sealious
Attached
Detach File
Event Timeline
Log In to Comment