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-24 11:10:28 -06:00
|
|
|
doipjs.serviceproviders.list.forEach((sp, i) => {
|
2020-10-23 14:35:53 -06:00
|
|
|
describe(`serviceproviders.${sp}`, () => {
|
|
|
|
it('should be an object', () => {
|
2020-10-24 11:10:28 -06:00
|
|
|
expect(doipjs.serviceproviders.data[sp]).to.be.a('object')
|
2020-10-23 14:35:53 -06:00
|
|
|
})
|
2020-10-24 03:18:35 -06:00
|
|
|
it('should have a RegExp instance named "reURI"', () => {
|
2020-10-24 11:10:28 -06:00
|
|
|
expect(doipjs.serviceproviders.data[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)', () => {
|
2020-10-24 11:10:28 -06:00
|
|
|
expect(doipjs.serviceproviders.data[sp].processURI).to.be.a('function')
|
|
|
|
expect(doipjs.serviceproviders.data[sp].processURI).to.have.length(2)
|
2020-10-23 14:35:53 -06:00
|
|
|
})
|
|
|
|
it('should have an array named "tests"', () => {
|
2020-10-24 11:10:28 -06:00
|
|
|
expect(doipjs.serviceproviders.data[sp].tests).to.be.instanceof(Array)
|
2020-10-23 14:35:53 -06:00
|
|
|
})
|
|
|
|
|
2020-10-24 11:10:28 -06:00
|
|
|
doipjs.serviceproviders.data[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}"`, () => {
|
2020-10-24 11:10:28 -06:00
|
|
|
expect(doipjs.serviceproviders.data[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}"`, () => {
|
2020-10-24 11:10:28 -06:00
|
|
|
expect(doipjs.serviceproviders.data[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
|
|
|
})
|