2017-05-22 12:03:45 -04:00
|
|
|
/* eslint-env mocha */
|
|
|
|
require('should')
|
|
|
|
var origin = require('../src/origin')
|
2014-05-08 08:47:51 -04:00
|
|
|
|
2017-05-22 12:03:45 -04:00
|
|
|
describe('Origin list', function () {
|
2014-05-08 08:47:51 -04:00
|
|
|
var list = [
|
|
|
|
'http://api.myapp.com',
|
|
|
|
'http://www.myapp.com'
|
2017-05-22 12:03:45 -04:00
|
|
|
]
|
2014-05-08 08:47:51 -04:00
|
|
|
|
2017-05-22 12:03:45 -04:00
|
|
|
it('returns null if the origin is not in the list', function () {
|
2014-05-08 08:47:51 -04:00
|
|
|
var o = origin.match('http://random-website.com', list);
|
2017-05-22 12:03:45 -04:00
|
|
|
(o === null).should.eql(true)
|
|
|
|
})
|
2014-05-08 08:47:51 -04:00
|
|
|
|
2017-05-22 12:03:45 -04:00
|
|
|
it('does not do partial matches', function () {
|
2014-05-08 08:47:51 -04:00
|
|
|
var o = origin.match('api.myapp.com', list);
|
2017-05-22 12:03:45 -04:00
|
|
|
(o === null).should.eql(true)
|
|
|
|
})
|
2014-05-08 08:47:51 -04:00
|
|
|
|
2017-05-22 12:03:45 -04:00
|
|
|
it('returns the origin if it matched', function () {
|
|
|
|
var o = origin.match('http://api.myapp.com', list)
|
|
|
|
o.should.eql('http://api.myapp.com')
|
|
|
|
})
|
2014-05-08 08:47:51 -04:00
|
|
|
|
2017-05-22 12:03:45 -04:00
|
|
|
it('returns the origin if the list contains *', function () {
|
|
|
|
var o = origin.match('http://random-website.com', ['*'])
|
|
|
|
o.should.eql('http://random-website.com')
|
|
|
|
})
|
|
|
|
})
|