aboutsummaryrefslogtreecommitdiffstats
path: root/__test__/user-mapping.test.js
blob: 8fdd613d457621f816381fd31f4eb2467955243b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
var _ = require('underscore');

var input = [];

function monitoringTemplateProtocol(input) {
    var nodeTypes = input;
    if (nodeTypes.length < 2) {
        if (nodeTypes[0] == 'FOI collector' || nodeTypes[0] == 'syslog') {
            return nodeTypes[0];
        } else {
            return 'other';
        }
    } else {
        var match = _.difference(nodeTypes, ["map", "enrich", "supplement"]);
        return match.length > 0 ? 'other' : 'SNMP';
    }
}

beforeEach(() => {
    input = [];
})

test('should return FOI', () => {
    input.push('FOI collector');
    expect(monitoringTemplateProtocol(input)).toBe('FOI collector');
})
test('should return Syslog', () => {
    input.push('syslog');
    expect(monitoringTemplateProtocol(input)).toBe('syslog');
})
test('should return SNMP', () => {
    input.push('map');
    input.push('enrich');
    input.push('supplement');
    input = _.shuffle(input);
    expect(monitoringTemplateProtocol(input)).toBe('SNMP');
})
test('should return other', () => {
    input.push('west');
    expect(monitoringTemplateProtocol(input)).toBe('other');
})