Permalink
Browse files

Merge pull request #1360 from leider/blanksagain

fixes #1356 without breaking legacy data
  • Loading branch information...
NicoleRauch committed Jun 30, 2018
2 parents 633d287 + cb38158 commit 8d950102a59a9e2d24963f595a6251d0f28deec0
@@ -6,7 +6,7 @@ function surroundWithLink(text) {
// shamelessly stolen from http://stackoverflow.com/questions/1500260/detect-urls-in-text-with-javascript
var urlRegex = /(\b(https?|ftp|file):\/\/[\-A-Z0-9+&@#\/%?=~_|!:,.;]*[\-A-Z0-9+&@#\/%=~_|])/ig;
return text.replace(urlRegex, function (url) {
return '<a href="' + url + '" target="_blank">' + '<i class="fa fa-external-link"/> ' + url + '</a>';
return '<a href="' + url + '" target="_blank">' + '<i class="fa fa-external-link"/> ' + url + ' </a>';
});
}
@@ -10,29 +10,29 @@
describe('surround with link', function () {
it('surrounds a text starting with "http" with a link consisting of the text', function () {
var result = surroundWithLink('http://my.link');
expect(result).to.equal('<a href="http://my.link" target="_blank"><i class="fa fa-external-link"/> http://my.link</a>');
expect(result).to.equal('<a href="http://my.link" target="_blank"><i class="fa fa-external-link"/> http://my.link </a>');
});
it('surrounds each link in a text with two "http" links', function () {
var result = surroundWithLink('http://my.link, http://your.link');
expect(result).to.equal('<a href="http://my.link" target="_blank"><i class="fa fa-external-link"/> http://my.link</a>, <a href="http://your.link" target="_blank"><i class="fa fa-external-link"/> http://your.link</a>');
expect(result).to.equal('<a href="http://my.link" target="_blank"><i class="fa fa-external-link"/> http://my.link </a>, <a href="http://your.link" target="_blank"><i class="fa fa-external-link"/> http://your.link </a>');
});
it('surrounds only links in a text', function () {
var result = surroundWithLink('http://my.link, your.link');
expect(result).to.equal('<a href="http://my.link" target="_blank"><i class="fa fa-external-link"/> http://my.link</a>, your.link');
expect(result).to.equal('<a href="http://my.link" target="_blank"><i class="fa fa-external-link"/> http://my.link </a>, your.link');
});
it('links an element inside class "urlify"', function () {
expect($('#first').html()).to.equal('<a href="http://my.first.link" target="_blank"><i class="fa fa-external-link"></i> http://my.first.link</a>');
expect($('#first').html()).to.equal('<a href="http://my.first.link" target="_blank"><i class="fa fa-external-link"></i> http://my.first.link </a>');
});
it('links two elements inside class "urlify"', function () {
expect($('#second').html()).to.equal('<a href="http://my.first.link" target="_blank"><i class="fa fa-external-link"></i> http://my.first.link</a>, <a href="http://my.first.link.again" target="_blank"><i class="fa fa-external-link"></i> http://my.first.link.again</a>');
expect($('#second').html()).to.equal('<a href="http://my.first.link" target="_blank"><i class="fa fa-external-link"></i> http://my.first.link </a>, <a href="http://my.first.link.again" target="_blank"><i class="fa fa-external-link"></i> http://my.first.link.again </a>');
});
it('links one of two elements inside class "urlify"', function () {
expect($('#third').html()).to.equal('<a href="http://my.first.link" target="_blank"><i class="fa fa-external-link"></i> http://my.first.link</a>, my.first.link.again');
expect($('#third').html()).to.equal('<a href="http://my.first.link" target="_blank"><i class="fa fa-external-link"></i> http://my.first.link </a>, my.first.link.again');
});
});
@@ -143,11 +143,11 @@ class Member {
}
interests() {
return this.state.interests;
return this.interestsForSelect2().join(', ');
}
interestsForSelect2() {
return (this.interests() || '').split(',').map(s => s.trim());
return (this.state.interests || '').split(',').map(s => s.trim());
}
reference() {
@@ -68,7 +68,8 @@ describe('Member initial filling', () => {
expect(member.twitter()).not.to.exist();
expect(member.location()).not.to.exist();
expect(member.profession()).not.to.exist();
expect(member.interests()).not.to.exist();
expect(member.state.interests).not.to.exist();
expect(member.interests()).to.eql('');
expect(member.site()).not.to.exist();
expect(member.reference()).not.to.exist();
});
@@ -92,7 +93,8 @@ describe('fillFromUI', () => {
expect(member.twitter()).not.to.exist();
expect(member.location()).not.to.exist();
expect(member.profession()).not.to.exist();
expect(member.interests()).not.to.exist();
expect(member.state.interests).not.to.exist();
expect(member.interests()).to.eql('');
expect(member.site()).not.to.exist();
expect(member.reference()).not.to.exist();
expect(member.notifyOnWikiChanges()).to.be.false();
@@ -128,6 +130,15 @@ describe('fillFromUI', () => {
expect(member.notifyOnWikiChanges()).to.be.true();
});
it('handles interests correctly - saving as string without blanks for legacy compatibilty - but displaying it with blanks', () => {
const record = {
interests: ['Everything', 'And more'],
};
const member = new Member().fillFromUI(record);
expect(member.state.interests).to.equal('Everything,And more');
expect(member.interests()).to.equal('Everything, And more');
});
});
describe('Member twitter field autocorrection', () => {

0 comments on commit 8d95010

Please sign in to comment.