diff --git a/ui/spec/shared/parsing/parseAlertaSpec.js b/ui/spec/shared/parsing/parseAlertaSpec.js deleted file mode 100644 index 9fe25b5ef7..0000000000 --- a/ui/spec/shared/parsing/parseAlertaSpec.js +++ /dev/null @@ -1,46 +0,0 @@ -import {parseAlerta} from 'shared/parsing/parseAlerta' - -it('can parse an alerta tick script', () => { - const tickScript = `stream - |alert() - .alerta() - .resource('Hostname or service') - .event('Something went wrong') - .environment('Development') - .group('Dev. Servers') - .services('a b c') - ` - - let actualObj = parseAlerta(tickScript) - - const expectedObj = [ - { - name: 'resource', - args: ['Hostname or service'], - }, - { - name: 'event', - args: ['Something went wrong'], - }, - { - name: 'environment', - args: ['Development'], - }, - { - name: 'group', - args: ['Dev. Servers'], - }, - { - name: 'services', - args: ['a', 'b', 'c'], - }, - ] - - // Test data structure - expect(actualObj).to.deep.equal(expectedObj) - - // Test that data structure is the same if fed back in - const expectedStr = `alerta().resource('Hostname or service').event('Something went wrong').environment('Development').group('Dev. Servers').services('a b c')` - actualObj = parseAlerta(expectedStr) - expect(actualObj).to.deep.equal(expectedObj) -}) diff --git a/ui/src/shared/parsing/parseAlerta.js b/ui/src/shared/parsing/parseAlerta.js deleted file mode 100644 index 10c920d032..0000000000 --- a/ui/src/shared/parsing/parseAlerta.js +++ /dev/null @@ -1,21 +0,0 @@ -const alertaRegex = /(services)\('(.+?)'\)|(resource)\('(.+?)'\)|(event)\('(.+?)'\)|(environment)\('(.+?)'\)|(group)\('(.+?)'\)|(origin)\('(.+?)'\)|(token)\('(.+?)'\)/gi - -export function parseAlerta(string) { - const properties = [] - let match - - while ((match = alertaRegex.exec(string))) { - // eslint-disable-line no-cond-assign - for (let m = 1; m < match.length; m += 2) { - if (match[m]) { - properties.push({ - name: match[m], - args: - match[m] === 'services' ? match[m + 1].split(' ') : [match[m + 1]], - }) - } - } - } - - return properties -}