From b62073c973f50b194577cc43ac34792fea32c491 Mon Sep 17 00:00:00 2001 From: mshanemc Date: Tue, 12 Nov 2024 16:33:31 -0600 Subject: [PATCH] test: url with port --- test/unit/status/myDomainResolver.test.ts | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/test/unit/status/myDomainResolver.test.ts b/test/unit/status/myDomainResolver.test.ts index ac12db42ce..ff5a932c24 100644 --- a/test/unit/status/myDomainResolver.test.ts +++ b/test/unit/status/myDomainResolver.test.ts @@ -20,7 +20,8 @@ describe('myDomainResolver', () => { const TEST_IP = '1.1.1.1'; const CALL_COUNT = 3; - let lookupAsyncSpy: { callCount: number }; + let lookupAsyncSpy: sinon.SinonStub; + beforeEach(() => { lookupAsyncSpy = $$.SANDBOX.stub(dns, 'lookup').callsFake((host: string, callback: AnyFunction) => { const isDefaultHost = host === MyDomainResolver.DEFAULT_DOMAIN.host; @@ -45,6 +46,17 @@ describe('myDomainResolver', () => { expect(lookupAsyncSpy.callCount).to.be.equal(CALL_COUNT); }); + it('should do lookup without port', async () => { + const options: MyDomainResolver.Options = { + url: new URL(`https://${POSITIVE_HOST}:6101`), + }; + const resolver: MyDomainResolver = await MyDomainResolver.create(options); + const ip = await resolver.resolve(); + expect(ip).to.be.equal(TEST_IP); + // verify that it uses hostname (without port) not host + expect(lookupAsyncSpy.args[0][0]).to.be.equal(POSITIVE_HOST); + }); + describe('disable dns check', () => { const env = new Env(); it('should return host if SFDX_DISABLE_DNS_CHECK is set to true', async () => {