1
1
mirror of https://github.com/leon-ai/leon.git synced 2024-12-20 15:21:36 +03:00
leon/packages/checker/test/isitdown.spec.js

58 lines
1.5 KiB
JavaScript
Raw Normal View History

2019-02-10 15:26:50 +03:00
'use strict'
describe('checker:isitdown', async () => {
test('detects invalid domain name', async () => {
global.nlu.brain.execute = jest.fn()
await global.nlu.process('Check if github is up')
2019-02-10 15:26:50 +03:00
const [obj] = global.nlu.brain.execute.mock.calls
await global.brain.execute(obj[0])
expect(global.brain.finalOutput.codes).toIncludeSameMembers(['invalid_domain_name'])
2019-02-10 15:26:50 +03:00
})
test('detects down domain name', async () => {
global.nlu.brain.execute = jest.fn()
await global.nlu.process('Check if fakedomainnametotestleon.fr is up')
2019-02-10 15:26:50 +03:00
const [obj] = global.nlu.brain.execute.mock.calls
await global.brain.execute(obj[0])
expect(global.brain.finalOutput.codes).toIncludeSameMembers([
'checking',
'down',
'done'
])
2019-02-10 15:26:50 +03:00
})
test('detects up domain name', async () => {
global.nlu.brain.execute = jest.fn()
await global.nlu.process('Check if github.com is up')
2019-02-10 15:26:50 +03:00
const [obj] = global.nlu.brain.execute.mock.calls
await global.brain.execute(obj[0])
expect(global.brain.finalOutput.codes).toIncludeSameMembers([
'checking',
'up',
'done'
])
2019-02-10 15:26:50 +03:00
})
test('detects up domain names', async () => {
global.nlu.brain.execute = jest.fn()
await global.nlu.process('Check if github.com and nodejs.org are up')
2019-02-10 15:26:50 +03:00
const [obj] = global.nlu.brain.execute.mock.calls
await global.brain.execute(obj[0])
expect(global.brain.finalOutput.codes).toIncludeSameMembers([
'checking',
'up',
'checking',
'up',
'done'
])
2019-02-10 15:26:50 +03:00
})
})