2020-04-29 18:44:27 +03:00
|
|
|
const should = require('should');
|
2016-05-17 16:06:12 +03:00
|
|
|
|
2020-04-29 18:44:27 +03:00
|
|
|
// Stuff we are testing
|
2021-10-06 12:52:46 +03:00
|
|
|
const twitter_url = require('../../../../core/frontend/helpers/twitter_url');
|
2016-05-17 16:06:12 +03:00
|
|
|
|
|
|
|
describe('{{twitter_url}} helper', function () {
|
2020-04-29 18:44:27 +03:00
|
|
|
const options = {data: {site: {}}};
|
2016-05-17 16:06:12 +03:00
|
|
|
|
|
|
|
beforeEach(function () {
|
2019-09-10 12:37:04 +03:00
|
|
|
options.data.site = {twitter: ''};
|
2016-05-17 16:06:12 +03:00
|
|
|
});
|
|
|
|
|
2019-09-10 12:37:04 +03:00
|
|
|
it('should output the twitter url for @site, if no other twitter username is provided', function () {
|
|
|
|
options.data.site = {twitter: '@hey'};
|
2016-05-17 16:06:12 +03:00
|
|
|
|
2021-10-04 18:30:54 +03:00
|
|
|
twitter_url.call({}, options).should.equal('https://twitter.com/hey');
|
2016-05-17 16:06:12 +03:00
|
|
|
});
|
|
|
|
|
|
|
|
it('should output the twitter url for the local object, if it has one', function () {
|
2019-09-10 12:37:04 +03:00
|
|
|
options.data.site = {twitter: '@hey'};
|
2016-05-17 16:06:12 +03:00
|
|
|
|
2021-10-04 18:30:54 +03:00
|
|
|
twitter_url.call({twitter: '@youthere'}, options).should.equal('https://twitter.com/youthere');
|
2016-05-17 16:06:12 +03:00
|
|
|
});
|
|
|
|
|
|
|
|
it('should output the twitter url for the provided username when it is explicitly passed in', function () {
|
2019-09-10 12:37:04 +03:00
|
|
|
options.data.site = {twitter: '@hey'};
|
2016-05-17 16:06:12 +03:00
|
|
|
|
2021-10-04 18:30:54 +03:00
|
|
|
twitter_url.call({twitter: '@youthere'}, '@iseeyouoverthere', options)
|
2016-05-17 16:06:12 +03:00
|
|
|
.should.equal('https://twitter.com/iseeyouoverthere');
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should return null if there are no twitter usernames', function () {
|
2021-10-04 18:30:54 +03:00
|
|
|
should.equal(twitter_url(options), null);
|
2016-05-17 16:06:12 +03:00
|
|
|
});
|
|
|
|
});
|