Fix and improve service provider tests

This commit is contained in:
Yarmo Mackenbach 2020-10-24 01:06:46 +02:00
parent cb9e82591f
commit e8aa308baa
3 changed files with 21 additions and 12 deletions

View file

@ -19,19 +19,15 @@ const processURL = (url, opts) => {
const tests = [ const tests = [
{ {
url: 'dns:example.org', url: 'dns:domain.org',
shouldMatch: true, shouldMatch: true
expectedProfileDisplay: 'example.org',
expectedProfileURL: 'https://example.org'
}, },
{ {
url: 'dns:example.org?type=TXT', url: 'dns:domain.org?type=TXT',
shouldMatch: true, shouldMatch: true
expectedProfileDisplay: 'example.org',
expectedProfileURL: 'https://example.org'
}, },
{ {
url: 'https://example.org', url: 'https://domain.org',
shouldMatch: false shouldMatch: false
} }
] ]

View file

@ -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.reURL = reURL
exports.processURL = processURL exports.processURL = processURL

View file

@ -51,11 +51,11 @@ for (let sp in doipjs.serviceproviders) {
doipjs.serviceproviders[sp].tests.forEach((test, i) => { doipjs.serviceproviders[sp].tests.forEach((test, i) => {
if (test.shouldMatch) { if (test.shouldMatch) {
it(`should match "${test.url}"`, () => { 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 { } else {
it(`should not match "${test.url}"`, () => { 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
}) })
} }
}); });