2018-12-20 03:41:04 -07:00
|
|
|
import * as assert from 'assert';
|
|
|
|
|
|
|
|
import extractMentions from '../src/misc/extract-mentions';
|
2021-04-01 19:36:11 -06:00
|
|
|
import { parse } from 'mfm-js';
|
2018-12-20 03:41:04 -07:00
|
|
|
|
|
|
|
describe('Extract mentions', () => {
|
|
|
|
it('simple', () => {
|
2020-01-08 22:35:04 -07:00
|
|
|
const ast = parse('@foo @bar @baz')!;
|
2018-12-20 03:41:04 -07:00
|
|
|
const mentions = extractMentions(ast);
|
|
|
|
assert.deepStrictEqual(mentions, [{
|
|
|
|
username: 'foo',
|
|
|
|
acct: '@foo',
|
|
|
|
host: null
|
|
|
|
}, {
|
|
|
|
username: 'bar',
|
|
|
|
acct: '@bar',
|
|
|
|
host: null
|
|
|
|
}, {
|
|
|
|
username: 'baz',
|
|
|
|
acct: '@baz',
|
|
|
|
host: null
|
|
|
|
}]);
|
|
|
|
});
|
|
|
|
|
|
|
|
it('nested', () => {
|
2020-01-08 22:35:04 -07:00
|
|
|
const ast = parse('@foo **@bar** @baz')!;
|
2018-12-20 03:41:04 -07:00
|
|
|
const mentions = extractMentions(ast);
|
|
|
|
assert.deepStrictEqual(mentions, [{
|
|
|
|
username: 'foo',
|
|
|
|
acct: '@foo',
|
|
|
|
host: null
|
|
|
|
}, {
|
|
|
|
username: 'bar',
|
|
|
|
acct: '@bar',
|
|
|
|
host: null
|
|
|
|
}, {
|
|
|
|
username: 'baz',
|
|
|
|
acct: '@baz',
|
|
|
|
host: null
|
|
|
|
}]);
|
|
|
|
});
|
|
|
|
});
|