mirror of
https://github.com/lowdefy/lowdefy.git
synced 2025-03-19 15:01:06 +08:00
fix(build): Events with try defined should add default for catch.
This commit is contained in:
parent
7a90f5b3ed
commit
bb36b55d7c
@ -64,7 +64,10 @@ function buildEvents(block, pageContext) {
|
||||
}". Received ${JSON.stringify(block.events[key].try)}`
|
||||
);
|
||||
}
|
||||
if (!type.isArray(block.events[key].catch) && !type.isNone(block.events[key].catch)) {
|
||||
if (type.isNone(block.events[key].catch)) {
|
||||
block.events[key].catch = [];
|
||||
}
|
||||
if (!type.isArray(block.events[key].catch)) {
|
||||
throw new Error(
|
||||
`Catch events must be an array of actions at "${
|
||||
block.blockId
|
||||
|
@ -120,6 +120,42 @@ test('block events actions as try catch arrays', async () => {
|
||||
]);
|
||||
});
|
||||
|
||||
test('block events actions as try array and catch not defined.', async () => {
|
||||
const components = {
|
||||
pages: [
|
||||
{
|
||||
id: 'page_1',
|
||||
type: 'Container',
|
||||
auth,
|
||||
blocks: [
|
||||
{
|
||||
id: 'block_1',
|
||||
type: 'Input',
|
||||
events: {
|
||||
onClick: {
|
||||
try: [
|
||||
{
|
||||
id: 'action_1',
|
||||
type: 'Reset',
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
};
|
||||
const res = await buildPages({ components, context });
|
||||
expect(get(res, 'pages.0.areas.content.blocks.0.events.onClick.try')).toEqual([
|
||||
{
|
||||
id: 'action_1',
|
||||
type: 'Reset',
|
||||
},
|
||||
]);
|
||||
expect(get(res, 'pages.0.areas.content.blocks.0.events.onClick.catch')).toEqual([]);
|
||||
});
|
||||
|
||||
test('block events actions try not an array', async () => {
|
||||
const components = {
|
||||
pages: [
|
||||
|
Loading…
x
Reference in New Issue
Block a user