mirror of
https://codeberg.org/keyoxide/doipjs.git
synced 2024-12-22 14:39:28 -07:00
Fix tests for async calls
This commit is contained in:
parent
33a2a7804a
commit
cf9176ff86
4 changed files with 43 additions and 14 deletions
22
package-lock.json
generated
22
package-lock.json
generated
|
@ -14,6 +14,7 @@
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"chai": "^4.2.0",
|
"chai": "^4.2.0",
|
||||||
|
"chai-as-promised": "^7.1.1",
|
||||||
"license-check-and-add": "^3.0.4",
|
"license-check-and-add": "^3.0.4",
|
||||||
"mocha": "^8.2.0",
|
"mocha": "^8.2.0",
|
||||||
"sinon": "^9.2.0",
|
"sinon": "^9.2.0",
|
||||||
|
@ -547,6 +548,18 @@
|
||||||
"type-detect": "^4.0.5"
|
"type-detect": "^4.0.5"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/chai-as-promised": {
|
||||||
|
"version": "7.1.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/chai-as-promised/-/chai-as-promised-7.1.1.tgz",
|
||||||
|
"integrity": "sha512-azL6xMoi+uxu6z4rhWQ1jbdUhOMhis2PvscD/xjLqNMkv3BPPp2JyyuTHOrf9BOosGpNQ11v6BKv/g57RXbiaA==",
|
||||||
|
"dev": true,
|
||||||
|
"dependencies": {
|
||||||
|
"check-error": "^1.0.2"
|
||||||
|
},
|
||||||
|
"peerDependencies": {
|
||||||
|
"chai": ">= 2.1.2 < 5"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/chalk": {
|
"node_modules/chalk": {
|
||||||
"version": "4.1.0",
|
"version": "4.1.0",
|
||||||
"resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.0.tgz",
|
"resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.0.tgz",
|
||||||
|
@ -3296,6 +3309,15 @@
|
||||||
"type-detect": "^4.0.5"
|
"type-detect": "^4.0.5"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"chai-as-promised": {
|
||||||
|
"version": "7.1.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/chai-as-promised/-/chai-as-promised-7.1.1.tgz",
|
||||||
|
"integrity": "sha512-azL6xMoi+uxu6z4rhWQ1jbdUhOMhis2PvscD/xjLqNMkv3BPPp2JyyuTHOrf9BOosGpNQ11v6BKv/g57RXbiaA==",
|
||||||
|
"dev": true,
|
||||||
|
"requires": {
|
||||||
|
"check-error": "^1.0.2"
|
||||||
|
}
|
||||||
|
},
|
||||||
"chalk": {
|
"chalk": {
|
||||||
"version": "4.1.0",
|
"version": "4.1.0",
|
||||||
"resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.0.tgz",
|
"resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.0.tgz",
|
||||||
|
|
|
@ -10,6 +10,7 @@
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"chai": "^4.2.0",
|
"chai": "^4.2.0",
|
||||||
|
"chai-as-promised": "^7.1.1",
|
||||||
"license-check-and-add": "^3.0.4",
|
"license-check-and-add": "^3.0.4",
|
||||||
"mocha": "^8.2.0",
|
"mocha": "^8.2.0",
|
||||||
"sinon": "^9.2.0",
|
"sinon": "^9.2.0",
|
||||||
|
|
|
@ -13,8 +13,11 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
See the License for the specific language governing permissions and
|
See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
*/
|
*/
|
||||||
const expect = require('chai').expect
|
const chai = require('chai')
|
||||||
const assert = require('chai').assert
|
const expect = chai.expect
|
||||||
|
const chaiAsPromised = require("chai-as-promised")
|
||||||
|
chai.use(chaiAsPromised)
|
||||||
|
|
||||||
const request = require('supertest')
|
const request = require('supertest')
|
||||||
const doipjs = require('../src')
|
const doipjs = require('../src')
|
||||||
|
|
||||||
|
|
|
@ -13,8 +13,11 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
See the License for the specific language governing permissions and
|
See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
*/
|
*/
|
||||||
const expect = require('chai').expect
|
const chai = require('chai')
|
||||||
const assert = require('chai').assert
|
const expect = chai.expect
|
||||||
|
const chaiAsPromised = require("chai-as-promised")
|
||||||
|
chai.use(chaiAsPromised)
|
||||||
|
|
||||||
const request = require('supertest')
|
const request = require('supertest')
|
||||||
const doipjs = require('../src')
|
const doipjs = require('../src')
|
||||||
|
|
||||||
|
@ -24,29 +27,29 @@ describe('verify', () => {
|
||||||
expect(doipjs.verify).to.have.length(3)
|
expect(doipjs.verify).to.have.length(3)
|
||||||
})
|
})
|
||||||
it('should throw an error for non-valid URIs', () => {
|
it('should throw an error for non-valid URIs', () => {
|
||||||
expect(() => { doipjs.verify('noURI') }).to.throw('Not a valid URI')
|
return expect(doipjs.verify('noURI')).to.eventually.be.rejectedWith('Not a valid URI')
|
||||||
expect(() => { doipjs.verify('domain.org') }).to.throw('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', () => {
|
it('should match "dns:domain.org" to the DNS service provider', async () => {
|
||||||
const matches = doipjs.verify('dns:domain.org', null, {returnMatchesOnly: true})
|
const matches = await doipjs.verify('dns: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('domain')
|
expect(matches[0].serviceprovider.name).to.be.equal('domain')
|
||||||
})
|
})
|
||||||
it('should match "xmpp:alice@domain.org" to the XMPP service provider', () => {
|
it('should match "xmpp:alice@domain.org" to the XMPP service provider', async () => {
|
||||||
const matches = doipjs.verify('xmpp:alice@domain.org', 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('xmpp')
|
expect(matches[0].serviceprovider.name).to.be.equal('xmpp')
|
||||||
})
|
})
|
||||||
it('should match "https://twitter.com/alice/status/1234567890123456789" to the Twitter service provider', () => {
|
it('should match "https://twitter.com/alice/status/1234567890123456789" to the Twitter service provider', async () => {
|
||||||
const matches = doipjs.verify('https://twitter.com/alice/status/1234567890123456789', null, {returnMatchesOnly: true})
|
const matches = await doipjs.verify('https://twitter.com/alice/status/1234567890123456789', 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('twitter')
|
expect(matches[0].serviceprovider.name).to.be.equal('twitter')
|
||||||
})
|
})
|
||||||
it('should match "https://news.ycombinator.com/user?id=Alice" to the Hackernews service provider', () => {
|
it('should match "https://news.ycombinator.com/user?id=Alice" to the Hackernews service provider', async () => {
|
||||||
const matches = doipjs.verify('https://news.ycombinator.com/user?id=Alice', null, {returnMatchesOnly: true})
|
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.a('array')
|
||||||
expect(matches).to.be.length(1)
|
expect(matches).to.be.length(1)
|
||||||
expect(matches[0].serviceprovider.name).to.be.equal('hackernews')
|
expect(matches[0].serviceprovider.name).to.be.equal('hackernews')
|
||||||
|
|
Loading…
Reference in a new issue