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 convert many alarms to a valid table', function() {
let NUM_ALARMS = 500;
let NUM_UNIQUE_PARM_NAMES = 50;
let NUM_PARMS_PER_ALARM = 5;
let alarms = [];
for (let i = 0; i < NUM_ALARMS; i++) {
let alarm = new Model.OnmsAlarm();
// Append a bunch of parameters
let parms = [];
for (let j = 0; j < NUM_PARMS_PER_ALARM; j++) {
parms.push(new Model.OnmsParm(
".1.3.6.1.2.1.15.3.1.14.39.252.8." + ((i + j) % NUM_UNIQUE_PARM_NAMES),
"10.1.1.1",
"string")
);
}
alarm.lastEvent = new Model.OnmsEvent();
alarm.lastEvent.parameters = parms;
alarms.push(alarm);
}
// Convert
let table = toTable(alarms);
// Expect # rows = # alarms
expect(table[0]['rows']).to.have.length(NUM_ALARMS);
it('should interpolate a variable with a number index', () => {
const ca = new CustomAction('foo', 'http://bar/$parameters[0]');
const alarm = new Model.OnmsAlarm();
alarm.parameters = [new Model.OnmsParm('blah', 'string', 'yo')];
expect(ca.interpolate(alarm)).to.equal('http://bar/yo');
});
it('should validate a variable with a string index', () => {
it('should interpolate a variable with a named event parm', () => {
const ca = new CustomAction('foo', 'http://bar/$parameters[monkey]');
const obj = new Model.OnmsAlarm();
obj.parameters = [
new Model.OnmsParm('monkey', 'Int32', '6')
];
expect(ca.interpolate(obj)).to.equal('http://bar/6');
});
});