diff --git a/client/src/lib-app/__tests__/mentions-parser-test.js b/client/src/lib-app/__tests__/mentions-parser-test.js
new file mode 100644
index 00000000..593efbd1
--- /dev/null
+++ b/client/src/lib-app/__tests__/mentions-parser-test.js
@@ -0,0 +1,71 @@
+root = 'ROOT_PATH';
+const mentionsParser = requireUnit('lib-app/mentions-parser', {});
+
+describe('MentionsParser library', function () {
+
+ it('should not parse text without mentions', function () {
+ expect(mentionsParser.parse(
+ 'This is an example without mentions'
+ )).to.equal(
+ 'This is an example without mentions'
+ );
+
+ expect(mentionsParser.parse(
+ 'This is an example without mentions abc
',
+ )).to.equal(
+ 'This is an example without mentions abc
',
+ );
+ });
+
+ it('should parse ticket number mention', function () {
+ expect(mentionsParser.parse(
+ 'This is an example with #123456'
+ )).to.equal(
+ 'This is an example with #123456'
+ );
+
+ expect(mentionsParser.parse(
+ 'This is an example with #487213 text'
+ )).to.equal(
+ 'This is an example with #487213 text'
+ );
+
+ expect(mentionsParser.parse(
+ 'This is an example with #487213text'
+ )).to.equal(
+ 'This is an example with #487213text'
+ );
+
+ expect(mentionsParser.parse(
+ 'This is an example with 4848#777777text'
+ )).to.equal(
+ 'This is an example with 4848#777777text'
+ );
+ });
+
+ it('should not parse invalid ticket number mention', function () {
+ expect(mentionsParser.parse(
+ 'This is an example with #12345'
+ )).to.equal(
+ 'This is an example with #12345'
+ );
+
+ expect(mentionsParser.parse(
+ 'This is an example with #12345abv hello'
+ )).to.equal(
+ 'This is an example with #12345abv hello'
+ );
+
+ expect(mentionsParser.parse(
+ 'This is an example with #a12345 hello'
+ )).to.equal(
+ 'This is an example with #a12345 hello'
+ );
+
+ expect(mentionsParser.parse(
+ 'This is an example with # hello'
+ )).to.equal(
+ 'This is an example with # hello'
+ );
+ });
+});
diff --git a/client/src/lib-app/mentions-parser.js b/client/src/lib-app/mentions-parser.js
index 52828b51..5a7f4593 100644
--- a/client/src/lib-app/mentions-parser.js
+++ b/client/src/lib-app/mentions-parser.js
@@ -37,13 +37,16 @@ class MentionsParser {
isDigit(string){
return /[0-9]/.test(string);
}
-
+
compileSegment(segment, parsingType){
switch(parsingType){
case PARSING_TEXT:
return segment;
case PARSING_MENTION:
- return '#' + segment + '';
+ if(segment.length == 6)
+ return '#' + segment + '';
+ else
+ return '#' + segment;
default:
return '';
}
diff --git a/tests/Makefile b/tests/Makefile
index 1b0d3002..b30f4e1c 100644
--- a/tests/Makefile
+++ b/tests/Makefile
@@ -7,7 +7,7 @@ install:
@bundle install
run: export MYSQL_HOST=127.0.0.1
-run: export MYSQL_PORT=3306
+run: export MYSQL_PORT=4040
run:
./run-tests.sh