From 06f1cdbe51f8775a76b3bf522547b2da40422c4c Mon Sep 17 00:00:00 2001 From: Preston Maness Date: Mon, 12 Jun 2023 00:19:56 -0500 Subject: [PATCH] Add tests --- test/utils.test.js | 31 ++++++++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) diff --git a/test/utils.test.js b/test/utils.test.js index 330bf81..f4dd71e 100644 --- a/test/utils.test.js +++ b/test/utils.test.js @@ -51,7 +51,7 @@ describe('utils.generateProxyURL', () => { expect(doipjs.utils.generateProxyURL).to.be.a('function') expect(doipjs.utils.generateProxyURL).to.have.length(3) }) - it('should generate correct proxy URLs', () => { + it('should generate correct proxy URLs for explicit https scheme', () => { const opts = { proxy: { hostname: 'localhost', @@ -65,6 +65,35 @@ describe('utils.generateProxyURL', () => { doipjs.utils.generateProxyURL('dns', { domain: 'domain.org' }, opts) ).to.equal('https://localhost/api/2/get/dns?domain=domain.org') }) + it('should generate correct proxy URLs for explicit http scheme', () => { + const opts = { + proxy: { + hostname: 'localhost', + scheme: 'http' + }, + } + expect( + doipjs.utils.generateProxyURL('http', { domain: 'domain.org' }, opts) + ).to.equal('http://localhost/api/2/get/http?domain=domain.org') + expect( + doipjs.utils.generateProxyURL('dns', { domain: 'domain.org' }, opts) + ).to.equal('http://localhost/api/2/get/dns?domain=domain.org') + }) + it('should generate correct proxy URLs for default scheme', () => { + const opts = { + proxy: { + hostname: 'localhost' + }, + } + expect( + doipjs.utils.generateProxyURL('http', { domain: 'domain.org' }, opts) + ).to.equal('https://localhost/api/2/get/http?domain=domain.org') + expect( + doipjs.utils.generateProxyURL('dns', { domain: 'domain.org' }, opts) + ).to.equal('https://localhost/api/2/get/dns?domain=domain.org') + }) + + }) describe('utils.getUriFromString', () => {