var should = require('should'), // jshint ignore:line makeAbsoluteUrls = require('../../../server/utils/make-absolute-urls'), configUtils = require('../../utils/configUtils'); describe('Make absolute URLs ', function () { var siteUrl = 'http://my-ghost-blog.com', itemUrl = 'my-awesome-post'; beforeEach(function () { configUtils.set({url: 'http://my-ghost-blog.com'}); }); afterEach(function () { configUtils.restore(); }); it('[success] does not convert absolute URLs', function () { var html = '', result = makeAbsoluteUrls(html, siteUrl, itemUrl).html(); result.should.match(//); }); it('[failure] does not convert protocol relative `//` URLs', function () { var html = '', result = makeAbsoluteUrls(html, siteUrl, itemUrl).html(); result.should.match(//); }); it('[failure] does not convert internal links starting with "#"', function () { var html = '', result = makeAbsoluteUrls(html, siteUrl, itemUrl).html(); result.should.match(//); }); it('[success] converts a relative URL', function () { var html = '', result = makeAbsoluteUrls(html, siteUrl, itemUrl).html(); result.should.match(//); }); it('[success] converts a relative URL including subdirectories', function () { var html = '', result = makeAbsoluteUrls(html, 'http://my-ghost-blog.com/blog', itemUrl).html(); result.should.match(//); }); });