Ghost/test/unit/frontend/helpers/twitter_url.test.js
Hannah Wolfe 95d27e7f58
Moved frontend unit tests into their own folder
- this is a small part of a bit of cleanup of our test files
- the goal is to make the existing tests clearer with a view to making it easier to write more tests
- this makes the test structure follow the codebase structure more closely
- eventually we will colocate the frontend tests with the frontend code
2021-10-06 11:58:29 +01:00

36 lines
1.2 KiB
JavaScript

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