From e8aa308baae6a1933385037c593acd60b3d0f980 Mon Sep 17 00:00:00 2001 From: Yarmo Mackenbach Date: Sat, 24 Oct 2020 01:06:46 +0200 Subject: [PATCH] Fix and improve service provider tests --- src/serviceproviders/dns.js | 14 +++++--------- src/serviceproviders/xmpp.js | 15 ++++++++++++++- test/serviceproviders.test.js | 4 ++-- 3 files changed, 21 insertions(+), 12 deletions(-) diff --git a/src/serviceproviders/dns.js b/src/serviceproviders/dns.js index acb64fe..be3e262 100644 --- a/src/serviceproviders/dns.js +++ b/src/serviceproviders/dns.js @@ -19,19 +19,15 @@ const processURL = (url, opts) => { const tests = [ { - url: 'dns:example.org', - shouldMatch: true, - expectedProfileDisplay: 'example.org', - expectedProfileURL: 'https://example.org' + url: 'dns:domain.org', + shouldMatch: true }, { - url: 'dns:example.org?type=TXT', - shouldMatch: true, - expectedProfileDisplay: 'example.org', - expectedProfileURL: 'https://example.org' + url: 'dns:domain.org?type=TXT', + shouldMatch: true }, { - url: 'https://example.org', + url: 'https://domain.org', shouldMatch: false } ] diff --git a/src/serviceproviders/xmpp.js b/src/serviceproviders/xmpp.js index cb0e3fa..3667e27 100644 --- a/src/serviceproviders/xmpp.js +++ b/src/serviceproviders/xmpp.js @@ -17,7 +17,20 @@ const processURL = (url, opts) => { } } -const tests = [] +const tests = [ + { + url: 'xmpp:alice@domain.org', + shouldMatch: true + }, + { + url: 'xmpp:alice@domain.org?omemo-sid-123456789=A1B2C3D4E5F6G7H8I9', + shouldMatch: true + }, + { + url: 'https://domain.org', + shouldMatch: false + } +] exports.reURL = reURL exports.processURL = processURL diff --git a/test/serviceproviders.test.js b/test/serviceproviders.test.js index d53d085..11a423a 100644 --- a/test/serviceproviders.test.js +++ b/test/serviceproviders.test.js @@ -51,11 +51,11 @@ for (let sp in doipjs.serviceproviders) { doipjs.serviceproviders[sp].tests.forEach((test, i) => { if (test.shouldMatch) { it(`should match "${test.url}"`, () => { - expect(doipjs.serviceproviders[sp].tests).to.be.true + expect(doipjs.serviceproviders[sp].reURL.test(test.url)).to.be.true }) } else { it(`should not match "${test.url}"`, () => { - expect(doipjs.serviceproviders[sp].tests).to.be.instanceof(Array) + expect(doipjs.serviceproviders[sp].reURL.test(test.url)).to.be.false }) } });