Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
it('should ignore well known tags', () => {
let bot1 = createBot('testId1', {
test: 'abc',
'aux._destroyed': true,
});
recent.addBotDiff(bot1);
expect(recent.bot).toEqual({
id: 'mod',
precalculated: true,
tags: {
test: 'abc',
},
values: {
test: 'abc',
},
});
it('should send an onBotsAdded event for all the bots in the partition on init', async () => {
const mem = createMemoryPartition({
type: 'memory',
initialState: {
test: createBot('test'),
test2: createBot('test2'),
},
});
let added: Bot[] = [];
mem.onBotsAdded.subscribe(e => added.push(...e));
expect(added).toEqual([createBot('test'), createBot('test2')]);
});
});
it('should send an onBotsAdded event for all the bots in the partition on init', async () => {
const mem = createMemoryPartition({
type: 'memory',
initialState: {
test: createBot('test'),
test2: createBot('test2'),
},
});
let added: Bot[] = [];
mem.onBotsAdded.subscribe(e => added.push(...e));
expect(added).toEqual([createBot('test'), createBot('test2')]);
});
});
it('should send an onBotsAdded event for all the bots in the partition on init', async () => {
const mem = createMemoryPartition({
type: 'memory',
initialState: {
test: createBot('test'),
test2: createBot('test2'),
},
});
let added: Bot[] = [];
mem.onBotsAdded.subscribe(e => added.push(...e));
expect(added).toEqual([createBot('test'), createBot('test2')]);
});
});
it('should move reused IDs to the front of the list with the new value', () => {
let bot1 = createBot('testId1', {
test: 'abc',
'aux.color': 'red',
});
let bot2 = createBot('testId2', {
test: 'abc',
'aux.color': 'green',
});
let bot3 = createBot('testId3', {
test: 'abc',
'aux.color': 'blue',
});
let bot1_2 = createBot('testId1', {
test1: '999',
'aux.color': 'magenta',
});
recent.addBotDiff(bot1);
recent.addBotDiff(bot2);
recent.addBotDiff(bot3);
recent.addBotDiff(bot1_2);
expect(recent.bot).toEqual({
id: 'mod',
precalculated: true,
it('should send removed atoms to the repo', async () => {
partition.connect();
await partition.applyEvents([
botAdded(
createBot('newBot', {
abc: 'def',
})
),
]);
await partition.applyEvents([
botUpdated('newBot', {
tags: {
abc: '123',
},
}),
]);
const addedAtoms = flatMap(
connection.sentMessages.filter(m => m.name === ADD_ATOMS),
m => m.data.atoms
it('should trim to the max length', () => {
let bot1 = createBot('testId1', {
test: 'abc',
'aux.color': 'red',
});
let bot2 = createBot('testId2', {
test: 'abc',
'aux.color': 'green',
});
let bot3 = createBot('testId3', {
test: 'abc',
'aux.color': 'blue',
});
let bot4 = createBot('testId4', {
test: 'abc',
'aux.color': 'magenta',
});
let bot5 = createBot('testId5', {
test: 'abc',
'aux.color': 'yellow',
});
let bot6 = createBot('testId6', {
it('should move reused IDs to the front of the list with the new value', () => {
let bot1 = createBot('testId1', {
test: 'abc',
'aux.color': 'red',
});
let bot2 = createBot('testId2', {
test: 'abc',
'aux.color': 'green',
});
let bot3 = createBot('testId3', {
test: 'abc',
'aux.color': 'blue',
});
let bot1_2 = createBot('testId1', {
test1: '999',
'aux.color': 'magenta',
});
recent.addBotDiff(bot1);
recent.addBotDiff(bot2);
recent.addBotDiff(bot3);
recent.addBotDiff(bot1_2);
expect(recent.bot).toEqual({
id: 'mod',
precalculated: true,
tags: {
...bot1_2.tags,
},
values: {
test: 'abc',
'aux.color': 'red',
});
let bot2 = createBot('testId2', {
test: 'abc',
'aux.color': 'green',
});
let bot3 = createBot('testId3', {
test: 'abc',
'aux.color': 'blue',
});
let bot4 = createBot('testId4', {
test: 'abc',
'aux.color': 'magenta',
});
let bot5 = createBot('testId5', {
test: 'abc',
'aux.color': 'yellow',
});
let bot6 = createBot('testId6', {
test: 'abc',
'aux.color': 'cyan',
});
recent.addBotDiff(bot1);
recent.addBotDiff(bot2);
recent.addBotDiff(bot3);
recent.addBotDiff(bot4);
recent.addBotDiff(bot5);
recent.addBotDiff(bot6);
expect(recent.bot).toEqual({
'aux._userSimulationsContext': 'abc',
}),
};
await helper.createSimulation('test', 'botId');
await helper.createSimulation('test2', 'botId2');
expect(vm.events).toEqual([
botAdded(
createBot('botId', {
abc: true,
'aux.channel': 'test',
})
),
botAdded(
createBot('botId2', {
abc: true,
'aux.channel': 'test2',
})
),
]);
});