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()
|
2019-03-05 03:38:18 +03:00
|
|
|
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])
|
|
|
|
|
2019-03-28 03:45:37 +03:00
|
|
|
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()
|
2021-04-22 14:06:02 +03:00
|
|
|
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])
|
|
|
|
|
2019-03-28 03:45:37 +03:00
|
|
|
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()
|
2019-03-05 03:38:18 +03:00
|
|
|
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])
|
|
|
|
|
2019-03-28 03:45:37 +03:00
|
|
|
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()
|
2019-03-05 03:38:18 +03:00
|
|
|
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])
|
|
|
|
|
2019-03-28 03:45:37 +03:00
|
|
|
expect(global.brain.finalOutput.codes).toIncludeSameMembers([
|
|
|
|
'checking',
|
|
|
|
'up',
|
|
|
|
'checking',
|
|
|
|
'up',
|
|
|
|
'done'
|
|
|
|
])
|
2019-02-10 15:26:50 +03:00
|
|
|
})
|
|
|
|
})
|