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

56 lines
1.5 KiB
JavaScript

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')
const [obj] = global.nlu.brain.execute.mock.calls
await global.brain.execute(obj[0])
expect(global.brain.finalOutput.codes).toIncludeSameMembers(['invalid_domain_name'])
})
test('detects down domain name', async () => {
global.nlu.brain.execute = jest.fn()
await global.nlu.process('Check if fakedomainnametotestleon.ai is up')
const [obj] = global.nlu.brain.execute.mock.calls
await global.brain.execute(obj[0])
expect(global.brain.finalOutput.codes).toIncludeSameMembers([
'checking',
'down',
'done'
])
})
test('detects up domain name', async () => {
global.nlu.brain.execute = jest.fn()
await global.nlu.process('Check if github.com is up')
const [obj] = global.nlu.brain.execute.mock.calls
await global.brain.execute(obj[0])
expect(global.brain.finalOutput.codes).toIncludeSameMembers([
'checking',
'up',
'done'
])
})
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')
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'
])
})
})