balena-supervisor/test/integration/mdns.spec.ts
Felipe Lalanne 6f02b17968 Refactor MDNS resolver into a module
Also add integration tests for the resolver functionality to prevent
regressions.

Change-type: patch
2024-04-23 19:23:32 -04:00

25 lines
819 B
TypeScript

import { expect } from 'chai';
import { promisify } from 'util';
import '~/src/mdns';
describe('MDNS', () => {
it('resolves global domain names', async () => {
const dns = require('dns'); // eslint-disable-line
const lookup = promisify(dns.lookup);
const res = await lookup('www.google.com', { all: true });
expect(res).to.not.be.null;
expect(res.length).to.be.greaterThan(0);
expect(Object.keys(res[0])).to.deep.equal(['address', 'family']);
});
it('resolves .local domain names', async () => {
const dns = require('dns'); // eslint-disable-line
const lookup = promisify(dns.lookup);
const res = await lookup('my-device.local', { all: true });
expect(res).to.not.be.null;
expect(res.length).to.be.greaterThan(0);
expect(Object.keys(res[0])).to.deep.equal(['address', 'family']);
});
});