mirror of
https://codeberg.org/keyoxide/doipjs.git
synced 2024-12-22 22:49:28 -07:00
Fix and improve service provider tests
This commit is contained in:
parent
cb9e82591f
commit
e8aa308baa
3 changed files with 21 additions and 12 deletions
|
@ -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
|
||||
}
|
||||
]
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
})
|
||||
}
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue