2018-12-20 04:41:04 -06:00
|
|
|
import * as assert from 'assert';
|
|
|
|
|
|
|
|
import extractMentions from '../src/misc/extract-mentions';
|
2019-01-30 01:56:27 -06:00
|
|
|
import { parse } from '../src/mfm/parse';
|
2018-12-20 04:41:04 -06:00
|
|
|
|
|
|
|
describe('Extract mentions', () => {
|
|
|
|
it('simple', () => {
|
|
|
|
const ast = parse('@foo @bar @baz');
|
|
|
|
const mentions = extractMentions(ast);
|
|
|
|
assert.deepStrictEqual(mentions, [{
|
|
|
|
username: 'foo',
|
|
|
|
acct: '@foo',
|
|
|
|
canonical: '@foo',
|
|
|
|
host: null
|
|
|
|
}, {
|
|
|
|
username: 'bar',
|
|
|
|
acct: '@bar',
|
|
|
|
canonical: '@bar',
|
|
|
|
host: null
|
|
|
|
}, {
|
|
|
|
username: 'baz',
|
|
|
|
acct: '@baz',
|
|
|
|
canonical: '@baz',
|
|
|
|
host: null
|
|
|
|
}]);
|
|
|
|
});
|
|
|
|
|
|
|
|
it('nested', () => {
|
|
|
|
const ast = parse('@foo **@bar** @baz');
|
|
|
|
const mentions = extractMentions(ast);
|
|
|
|
assert.deepStrictEqual(mentions, [{
|
|
|
|
username: 'foo',
|
|
|
|
acct: '@foo',
|
|
|
|
canonical: '@foo',
|
|
|
|
host: null
|
|
|
|
}, {
|
|
|
|
username: 'bar',
|
|
|
|
acct: '@bar',
|
|
|
|
canonical: '@bar',
|
|
|
|
host: null
|
|
|
|
}, {
|
|
|
|
username: 'baz',
|
|
|
|
acct: '@baz',
|
|
|
|
canonical: '@baz',
|
|
|
|
host: null
|
|
|
|
}]);
|
|
|
|
});
|
|
|
|
});
|