2020-10-23 14:35:53 -06:00
|
|
|
/*
|
2020-10-24 07:11:14 -06:00
|
|
|
Copyright 2020 Yarmo Mackenbach
|
2020-10-23 14:35:53 -06:00
|
|
|
|
2020-10-24 07:11:14 -06:00
|
|
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
you may not use this file except in compliance with the License.
|
|
|
|
You may obtain a copy of the License at
|
2020-10-23 14:35:53 -06:00
|
|
|
|
2020-10-24 07:11:14 -06:00
|
|
|
http://www.apache.org/licenses/LICENSE-2.0
|
2020-10-23 14:35:53 -06:00
|
|
|
|
2020-10-24 07:11:14 -06:00
|
|
|
Unless required by applicable law or agreed to in writing, software
|
|
|
|
distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
See the License for the specific language governing permissions and
|
|
|
|
limitations under the License.
|
2020-10-23 14:35:53 -06:00
|
|
|
*/
|
|
|
|
const expect = require('chai').expect
|
|
|
|
const assert = require('chai').assert
|
|
|
|
const request = require('supertest')
|
|
|
|
const doipjs = require('../src')
|
|
|
|
|
2020-10-23 17:25:21 -06:00
|
|
|
doipjs.serviceprovidersList.forEach((sp, i) => {
|
2020-10-23 14:35:53 -06:00
|
|
|
describe(`serviceproviders.${sp}`, () => {
|
|
|
|
it('should be an object', () => {
|
|
|
|
expect(doipjs.serviceproviders[sp]).to.be.a('object')
|
|
|
|
})
|
2020-10-24 03:18:35 -06:00
|
|
|
it('should have a RegExp instance named "reURI"', () => {
|
|
|
|
expect(doipjs.serviceproviders[sp].reURI).to.be.instanceof(RegExp)
|
2020-10-23 14:35:53 -06:00
|
|
|
})
|
2020-10-24 03:24:30 -06:00
|
|
|
it('should have a function named "processURI" (2 arguments)', () => {
|
|
|
|
expect(doipjs.serviceproviders[sp].processURI).to.be.a('function')
|
|
|
|
expect(doipjs.serviceproviders[sp].processURI).to.have.length(2)
|
2020-10-23 14:35:53 -06:00
|
|
|
})
|
|
|
|
it('should have an array named "tests"', () => {
|
|
|
|
expect(doipjs.serviceproviders[sp].tests).to.be.instanceof(Array)
|
|
|
|
})
|
|
|
|
|
2020-10-23 17:25:21 -06:00
|
|
|
doipjs.serviceproviders[sp].tests.forEach((test, j) => {
|
2020-10-23 14:35:53 -06:00
|
|
|
if (test.shouldMatch) {
|
2020-10-24 03:18:35 -06:00
|
|
|
it(`should match "${test.uri}"`, () => {
|
|
|
|
expect(doipjs.serviceproviders[sp].reURI.test(test.uri)).to.be.true
|
2020-10-23 14:35:53 -06:00
|
|
|
})
|
|
|
|
} else {
|
2020-10-24 03:18:35 -06:00
|
|
|
it(`should not match "${test.uri}"`, () => {
|
|
|
|
expect(doipjs.serviceproviders[sp].reURI.test(test.uri)).to.be.false
|
2020-10-23 14:35:53 -06:00
|
|
|
})
|
|
|
|
}
|
2020-10-23 17:25:21 -06:00
|
|
|
})
|
2020-10-23 14:35:53 -06:00
|
|
|
|
|
|
|
})
|
2020-10-23 17:25:21 -06:00
|
|
|
})
|