mirror of
https://codeberg.org/keyoxide/doipjs.git
synced 2024-12-22 22:49:28 -07:00
Automatically generate tests for every service provider
This commit is contained in:
parent
8e4ed49aec
commit
d5dfbb3626
1 changed files with 13 additions and 34 deletions
|
@ -55,39 +55,18 @@ describe('verify', () => {
|
||||||
return expect(doipjs.verify('noURI')).to.eventually.be.rejectedWith('Not a valid URI')
|
return expect(doipjs.verify('noURI')).to.eventually.be.rejectedWith('Not a valid URI')
|
||||||
return expect(doipjs.verify('domain.org')).to.eventually.be.rejectedWith('Not a valid URI')
|
return expect(doipjs.verify('domain.org')).to.eventually.be.rejectedWith('Not a valid URI')
|
||||||
})
|
})
|
||||||
it('should match "dns:domain.org" to the DNS service provider', async () => {
|
|
||||||
const matches = await doipjs.verify('dns:domain.org', null, {returnMatchesOnly: true})
|
doipjs.serviceproviders.list.forEach((spName, i) => {
|
||||||
expect(matches).to.be.a('array')
|
const sp = doipjs.serviceproviders.data[spName]
|
||||||
expect(matches).to.be.length(1)
|
|
||||||
expect(matches[0].serviceprovider.name).to.be.equal('domain')
|
if (sp.tests.length == 0) { return }
|
||||||
expect(matches[0]).to.matchPattern(pattern)
|
|
||||||
})
|
it(`should return a valid object for the "${spName}" service provider`, async () => {
|
||||||
it('should match "xmpp:alice@domain.org" to the XMPP service provider', async () => {
|
const matches = await doipjs.verify(sp.tests[0].uri, null, {returnMatchesOnly: true})
|
||||||
const matches = await doipjs.verify('xmpp:alice@domain.org', null, {returnMatchesOnly: true})
|
expect(matches).to.be.a('array')
|
||||||
expect(matches).to.be.a('array')
|
expect(matches).to.be.length(1)
|
||||||
expect(matches).to.be.length(1)
|
expect(matches[0].serviceprovider.name).to.be.equal(spName)
|
||||||
expect(matches[0].serviceprovider.name).to.be.equal('xmpp')
|
expect(matches[0]).to.matchPattern(pattern)
|
||||||
expect(matches[0]).to.matchPattern(pattern)
|
})
|
||||||
})
|
|
||||||
it('should match "https://twitter.com/alice/status/1234567890123456789" to the Twitter service provider', async () => {
|
|
||||||
const matches = await doipjs.verify('https://twitter.com/alice/status/1234567890123456789', null, {returnMatchesOnly: true})
|
|
||||||
expect(matches).to.be.a('array')
|
|
||||||
expect(matches).to.be.length(1)
|
|
||||||
expect(matches[0].serviceprovider.name).to.be.equal('twitter')
|
|
||||||
expect(matches[0]).to.matchPattern(pattern)
|
|
||||||
})
|
|
||||||
it('should match "https://news.ycombinator.com/user?id=Alice" to the Hackernews service provider', async () => {
|
|
||||||
const matches = await doipjs.verify('https://news.ycombinator.com/user?id=Alice', null, {returnMatchesOnly: true})
|
|
||||||
expect(matches).to.be.a('array')
|
|
||||||
expect(matches).to.be.length(1)
|
|
||||||
expect(matches[0].serviceprovider.name).to.be.equal('hackernews')
|
|
||||||
expect(matches[0]).to.matchPattern(pattern)
|
|
||||||
})
|
|
||||||
it('should match "https://lobste.rs/u/Alice" to the Lobsters service provider', async () => {
|
|
||||||
const matches = await doipjs.verify('https://lobste.rs/u/Alice', null, {returnMatchesOnly: true})
|
|
||||||
expect(matches).to.be.a('array')
|
|
||||||
expect(matches).to.be.length(1)
|
|
||||||
expect(matches[0].serviceprovider.name).to.be.equal('lobsters')
|
|
||||||
expect(matches[0]).to.matchPattern(pattern)
|
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
Loading…
Reference in a new issue