Ghost/test/unit/helpers/facebook_url.test.js
Hannah Wolfe f08a55c21f
Renamed tests to .test.js & updated commands
refs: https://github.com/TryGhost/Team/issues/856
refs: https://github.com/TryGhost/Team/issues/756

- The .test.js extension is better than _spec.js as it's more obvious that it's an extension
- It also meaans we can use the --extension parameter in mocha, which should result in a better default behaviour for `yarn test`
- It also highlights that some of our tests were named incorrectly and were not (and still will not be) run (see https://github.com/TryGhost/Team/issues/856)
- Note: even with this change, `yarn test` is throwing errors, I believe because of this issue https://github.com/TryGhost/Team/issues/756
2021-07-06 20:45:01 +01:00

37 lines
1.3 KiB
JavaScript

const should = require('should');
// Stuff we are testing
const helpers = require('../../../core/frontend/helpers');
describe('{{facebook_url}} helper', function () {
const options = {data: {site: {}}};
beforeEach(function () {
options.data.site = {facebook: ''};
});
it('should output the facebook url for @site, if no other facebook username is provided', function () {
options.data.site = {facebook: 'hey'};
helpers.facebook_url.call({}, options).should.equal('https://www.facebook.com/hey');
});
it('should output the facebook url for the local object, if it has one', function () {
options.data.site = {facebook: 'hey'};
helpers.facebook_url.call({facebook: 'you/there'}, options).should.equal('https://www.facebook.com/you/there');
});
it('should output the facebook url for the provided username when it is explicitly passed in', function () {
options.data.site = {facebook: 'hey'};
helpers.facebook_url.call({facebook: 'you/there'}, 'i/see/you/over/there', options)
.should.equal('https://www.facebook.com/i/see/you/over/there');
});
it('should return null if there are no facebook usernames', function () {
should.equal(helpers.facebook_url(options), null);
});
});