Commit 61be1415 authored by Ben Hayward's avatar Ben Hayward

Lint

1 merge request!436[Sprint/InterestingIguana](feat) Show error on hashtag limit when editing post #867
Pipeline #81397449 running with stages
......@@ -2,25 +2,30 @@ import { TopbarHashtagsService } from './topbar.service';
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
describe('TopbarHashtagsService', () => {
let client = null;
let hashtagsService = new TopbarHashtagsService(client);
it('should split hashtags from a message correctly', function(done) {
const input = '#begin foobar #Has #Hell123 #hello and #what, #ending';
const expectedResult =
['begin', 'Has', 'Hell123', 'hello', 'what', 'ending'];
const input = '#begin foobar #Has #Hell123 #hello and #what, #ending';
const expectedResult = [
'begin',
'Has',
'Hell123',
'hello',
'what',
'ending',
];
const result = hashtagsService.sliceHashTags(input);
expect(result).toEqual(expectedResult);
done();
const result = hashtagsService.sliceHashTags(input);
expect(result).toEqual(expectedResult);
done();
});
it('should return an empty array if the message has no hashtags', function(done) {
const input = 'foo bar.';
const result = hashtagsService.sliceHashTags(input);
const input = 'foo bar.';
const result = hashtagsService.sliceHashTags(input);
expect(result).toEqual([]);
done();
expect(result).toEqual([]);
done();
});
});
......@@ -99,14 +99,13 @@ export class TopbarHashtagsService {
* Credit to Arnaud Valensi - http://geekcoder.org/js-extract-hashtags-from-text/
*/
sliceHashTags(inputText: any) {
sliceHashTags(inputText: any) {
const regex = /(?:^|\s)(?:#)([a-zA-Z\d]+)/gm;
let matches = [];
let match;
while ((match = regex.exec(inputText))) {
matches.push(match[1]);
matches.push(match[1]);
}
return matches;
}
}
......@@ -24,7 +24,7 @@ export class ActivityPreview {
minds = window.Minds;
activity: any;
hideTabs: boolean;
editing: boolean = false;
errorString: string = null;
commentsToggle: boolean = false;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment