Test Multiple event handlers
parent
9f1389aae5
commit
a943e590c7
File diff suppressed because one or more lines are too long
|
@ -0,0 +1,25 @@
|
||||||
|
import parseHandlersFromConfig from 'shared/parsing/parseHandlersFromConfig'
|
||||||
|
import {
|
||||||
|
config,
|
||||||
|
configResponse,
|
||||||
|
emptyConfig,
|
||||||
|
emptyConfigResponse,
|
||||||
|
} from './constants'
|
||||||
|
|
||||||
|
describe('parseHandlersFromConfig', () => {
|
||||||
|
it('returns an array', () => {
|
||||||
|
const input = config
|
||||||
|
const actual = parseHandlersFromConfig(input)
|
||||||
|
expect(actual).to.be.a('array')
|
||||||
|
})
|
||||||
|
it('returns the right response', () => {
|
||||||
|
const input = config
|
||||||
|
const actual = parseHandlersFromConfig(input)
|
||||||
|
expect(actual).to.deep.equal(configResponse)
|
||||||
|
})
|
||||||
|
it('returns the right response even if config is empty', () => {
|
||||||
|
const input = emptyConfig
|
||||||
|
const actual = parseHandlersFromConfig(input)
|
||||||
|
expect(actual).to.deep.equal(emptyConfigResponse)
|
||||||
|
})
|
||||||
|
})
|
|
@ -0,0 +1,42 @@
|
||||||
|
import {parseHandlersFromRule} from 'shared/parsing/parseHandlersFromRule'
|
||||||
|
import {
|
||||||
|
emptyRule,
|
||||||
|
emptyConfigResponse,
|
||||||
|
rule,
|
||||||
|
handlersFromConfig,
|
||||||
|
handlersOfKind_expected,
|
||||||
|
selectedHandler_expected,
|
||||||
|
handlersOnThisAlert_expected,
|
||||||
|
} from './constants'
|
||||||
|
|
||||||
|
describe('parseHandlersFromRule', () => {
|
||||||
|
it('returns empty things if rule is new and config is empty', () => {
|
||||||
|
const input1 = emptyRule
|
||||||
|
const input2 = emptyConfigResponse
|
||||||
|
const {
|
||||||
|
handlersOnThisAlert,
|
||||||
|
selectedHandler,
|
||||||
|
handlersOfKind,
|
||||||
|
} = parseHandlersFromRule(input1, input2)
|
||||||
|
const handlersOnThisAlert_expected = []
|
||||||
|
const selectedHandler_expected = null
|
||||||
|
const handlersOfKind_expected = {}
|
||||||
|
expect(handlersOnThisAlert).to.deep.equal(handlersOnThisAlert_expected)
|
||||||
|
expect(selectedHandler).to.deep.equal(selectedHandler_expected)
|
||||||
|
expect(handlersOfKind).to.deep.equal(handlersOfKind_expected)
|
||||||
|
})
|
||||||
|
|
||||||
|
it('returns values if rule and config are not empty', () => {
|
||||||
|
const input1 = rule
|
||||||
|
const input2 = handlersFromConfig
|
||||||
|
const {
|
||||||
|
handlersOnThisAlert,
|
||||||
|
selectedHandler,
|
||||||
|
handlersOfKind,
|
||||||
|
} = parseHandlersFromRule(input1, input2)
|
||||||
|
|
||||||
|
expect(handlersOnThisAlert).to.deep.equal(handlersOnThisAlert_expected)
|
||||||
|
expect(selectedHandler).to.deep.equal(selectedHandler_expected)
|
||||||
|
expect(handlersOfKind).to.deep.equal(handlersOfKind_expected)
|
||||||
|
})
|
||||||
|
})
|
Loading…
Reference in New Issue