summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorunarist <m.unarist@gmail.com>2018-04-09 01:10:04 +0900
committerunarist <m.unarist@gmail.com>2018-04-09 01:52:41 +0900
commit3c4235067f2ff1f8057080482559a8015f0492c6 (patch)
tree8ed49d9d10af0e7f9f70b27cb7dfb6f0173b0d4a /test
parentMerge pull request #1420 from unarist/fix/banner-selection (diff)
downloadmisskey-3c4235067f2ff1f8057080482559a8015f0492c6.tar.gz
misskey-3c4235067f2ff1f8057080482559a8015f0492c6.tar.bz2
misskey-3c4235067f2ff1f8057080482559a8015f0492c6.zip
Fix username/mention regexes
* Allow underscore instead of hypen * Fix domain part handling * Add tests for remote mention
Diffstat (limited to 'test')
-rw-r--r--test/text.ts14
1 files changed, 12 insertions, 2 deletions
diff --git a/test/text.ts b/test/text.ts
index 711aad8167..8ce55cd1bc 100644
--- a/test/text.ts
+++ b/test/text.ts
@@ -9,9 +9,11 @@ const syntaxhighlighter = require('../built/text/parse/core/syntax-highlighter')
describe('Text', () => {
it('can be analyzed', () => {
- const tokens = analyze('@himawari お腹ペコい :cat: #yryr');
+ const tokens = analyze('@himawari @hima_sub@namori.net お腹ペコい :cat: #yryr');
assert.deepEqual([
{ type: 'mention', content: '@himawari', username: 'himawari', host: null },
+ { type: 'text', content: ' '},
+ { type: 'mention', content: '@hima_sub@namori.net', username: 'hima_sub', host: 'namori.net' },
{ type: 'text', content: ' お腹ペコい ' },
{ type: 'emoji', content: ':cat:', emoji: 'cat'},
{ type: 'text', content: ' '},
@@ -20,7 +22,7 @@ describe('Text', () => {
});
it('can be inverted', () => {
- const text = '@himawari お腹ペコい :cat: #yryr';
+ const text = '@himawari @hima_sub@namori.net お腹ペコい :cat: #yryr';
assert.equal(analyze(text).map(x => x.content).join(''), text);
});
@@ -41,6 +43,14 @@ describe('Text', () => {
], tokens);
});
+ it('remote mention', () => {
+ const tokens = analyze('@hima_sub@namori.net お腹ペコい');
+ assert.deepEqual([
+ { type: 'mention', content: '@hima_sub@namori.net', username: 'hima_sub', host: 'namori.net' },
+ { type: 'text', content: ' お腹ペコい' }
+ ], tokens);
+ });
+
it('hashtag', () => {
const tokens = analyze('Strawberry Pasta #alice');
assert.deepEqual([