-
Notifications
You must be signed in to change notification settings - Fork 115
/
Copy pathgetBaseUrl.js
29 lines (24 loc) · 1.37 KB
/
getBaseUrl.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
var expect = require('chai').expect;
var OAuth = require('../oauth-1.0a');
describe('#getBaseUrl', function() {
var oauth = new OAuth({consumer: {}});
beforeEach(function () {
oauth = new OAuth({consumer: {}});
});
it('should return base url', function () {
expect(oauth.getBaseUrl('http://example.com/path/')).to.equal('http://example.com/path/');
expect(oauth.getBaseUrl('http://example.com/path/?foo=bar')).to.equal('http://example.com/path/');
});
it('should exclude default port number', function () {
expect(oauth.getBaseUrl('http://example.com/')).to.equal('http://example.com/');
expect(oauth.getBaseUrl('http://example.com:80/')).to.equal('http://example.com/');
expect(oauth.getBaseUrl('https://example.com/')).to.equal('https://example.com/');
expect(oauth.getBaseUrl('https://example.com:443/')).to.equal('https://example.com/');
});
it('should include non-default port number', function () {
expect(oauth.getBaseUrl('http://example.com:8080/')).to.equal('http://example.com:8080/');
expect(oauth.getBaseUrl('http://example.com:443/')).to.equal('http://example.com:443/');
expect(oauth.getBaseUrl('https://example.com:8080/')).to.equal('https://example.com:8080/');
expect(oauth.getBaseUrl('https://example.com:80/')).to.equal('https://example.com:80/');
});
});