summaryrefslogtreecommitdiff
path: root/test/specs/helpers/combineURLs.spec.js
diff options
context:
space:
mode:
Diffstat (limited to 'test/specs/helpers/combineURLs.spec.js')
-rw-r--r--test/specs/helpers/combineURLs.spec.js23
1 files changed, 23 insertions, 0 deletions
diff --git a/test/specs/helpers/combineURLs.spec.js b/test/specs/helpers/combineURLs.spec.js
new file mode 100644
index 0000000..2a427f5
--- /dev/null
+++ b/test/specs/helpers/combineURLs.spec.js
@@ -0,0 +1,23 @@
+var combineURLs = require('../../../lib/helpers/combineURLs');
+
+describe('helpers::combineURLs', function () {
+ it('should combine URLs', function () {
+ expect(combineURLs('https://api.github.com', '/users')).toBe('https://api.github.com/users');
+ });
+
+ it('should remove duplicate slashes', function () {
+ expect(combineURLs('https://api.github.com/', '/users')).toBe('https://api.github.com/users');
+ });
+
+ it('should insert missing slash', function () {
+ expect(combineURLs('https://api.github.com', 'users')).toBe('https://api.github.com/users');
+ });
+
+ it('should not insert slash when relative url missing/empty', function () {
+ expect(combineURLs('https://api.github.com/users', '')).toBe('https://api.github.com/users');
+ });
+
+ it('should allow a single slash for relative url', function () {
+ expect(combineURLs('https://api.github.com/users', '/')).toBe('https://api.github.com/users/');
+ });
+});