1
1
mirror of https://github.com/leon-ai/leon.git synced 2024-12-27 10:43:12 +03:00
leon/packages/checker/test/isitdown.spec.js

56 lines
1.5 KiB
JavaScript
Raw Normal View History

2021-12-27 13:37:42 +03:00
describe('checker:isitdown', () => {
2019-02-10 15:26:50 +03:00
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.ai 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
})
})