Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
channel.remoteEvents.subscribe(e => events.push(...e));
await channel.sendEvents([
{
type: 'device',
device: device,
event: echo('test'),
},
]);
// Wait for the async operations to finish
await Promise.resolve();
await Promise.resolve();
expect(events).toEqual([
remote(action('test'), {
sessionId: device.claims[SESSION_ID_CLAIM],
}),
]);
});
});
try {
await simulation.init();
if (event.botOrMod) {
console.log(`[SetupChannelModule2] Creating new bot`);
const botId = await simulation.helper.createBot(
undefined,
isBot(event.botOrMod)
? event.botOrMod.tags
: event.botOrMod
);
console.log(
`[SetupChannelModule2] Created bot ${botId}`
);
await simulation.helper.transaction(
action(
CREATE_ACTION_NAME,
[botId],
simulation.helper.userId
)
);
}
} finally {
simulation.unsubscribe();
}
}
} catch (err) {
console.error('[SetupChannelModule2]', err);
}
}
}
it('should run action events', async () => {
await helper.createFile('test', {
'action()': 'setTag(this, "#hit", true)',
});
await helper.transaction(action('action', ['test'], 'user'));
expect(helper.filesState['test'].tags.hit).toBe(true);
});
);
const channel = await this._channelManager.loadChannel(
newChannelInfo
);
if (event.botOrMod) {
console.log(`[SetupChannelModule] Creating new bot`);
const botId = await channel.channel.helper.createBot(
undefined,
isBot(event.botOrMod)
? event.botOrMod.tags
: event.botOrMod
);
console.log(`[SetupChannelModule] Created bot ${botId}`);
await channel.channel.helper.transaction(
action(
CREATE_ACTION_NAME,
[botId],
channel.channel.helper.userId
)
);
}
}
} catch (err) {
console.error('[SetupChannelModule]', err);
}
}
}
private async _sendCallback(
event: SaveFileAction | LoadFileAction,
channel: NodeAuxChannel,
arg: any
) {
if (event.options.callbackShout) {
await channel.helper.transaction(
action(
event.options.callbackShout,
null,
channel.helper.userId,
arg
)
);
}
}