You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

19 lines
743 B

import { validateHost } from 'lib/lnd/util'
jest.mock('dns')
describe('Util', function() {
describe('validateHost', () => {
it('should resolve true for valid hostnames', async () => {
await expect(validateHost('example.com')).resolves.toBeTruthy()
await expect(validateHost('localhost')).resolves.toBeTruthy()
await expect(validateHost('192.168.0.1')).resolves.toBeTruthy()
await expect(validateHost('11.111.11.111.rdns.example.com')).resolves.toBeTruthy()
})
it('should reject for invalid hostnames', async () => {
await expect(validateHost('1+-000invlidhost')).rejects.toThrowErrorMatchingInlineSnapshot(
`"1+-000invlidhost is not a valid IP address or hostname"`
)
})
})
})