Files: fc02f66dceda67c641acd004d40ad96716ce2e46 / test / mentions.js
1701 bytesRaw
1 | var test = require('tape') |
2 | var mentions = require('../') |
3 | |
4 | var id = { |
5 | feed: '@3HO6R2i60XNR3h6XCHAWCdt1k9Dwy+gaa2rVs6LzZ6Y=.ed25519', |
6 | msg: '%A2LvseOYKDXyuSGlXl3Sz0F5j2khVCN6JTf8ORD/tM8=.sha256', |
7 | blob: '&9SSTQys34p9f4zqjxvRwENjFX0JapgtesRey7+fxK14=.sha256' |
8 | } |
9 | id.all = [id.feed, id.msg, id.blob].join(' ') |
10 | |
11 | var text = { |
12 | feed: '[@feed](' + id.feed + ')', |
13 | msg: '[a msg](' + id.msg + ')', |
14 | blob: '[a blob](' + id.blob + ')' |
15 | } |
16 | text.all = [text.feed, text.msg, text.blob].join(' ') |
17 | |
18 | var linkMention = { |
19 | feed: [ { link: id.feed, name: 'feed', rel: 'mentions' } ], |
20 | msg: [ { link: id.msg, name: 'a msg', rel: 'mentions' } ], |
21 | blob: [ { link: id.blob, name: 'a blob', rel: 'mentions' } ] |
22 | } |
23 | linkMention.all = linkMention.feed.concat(linkMention.msg, linkMention.blob) |
24 | |
25 | test('mentions in links are detected', function (t) { |
26 | t.deepEquals(mentions(text.feed), linkMention.feed, 'feed link') |
27 | t.deepEquals(mentions(text.msg), linkMention.msg, 'msg link') |
28 | t.deepEquals(mentions(text.blob), linkMention.blob, 'blob link') |
29 | t.deepEquals(mentions(text.all), linkMention.all, 'all links') |
30 | t.end() |
31 | }) |
32 | |
33 | var refMention = { |
34 | feed: [ { link: id.feed, name: undefined, rel: 'mentions' } ], |
35 | msg: [ { link: id.msg, name: undefined, rel: 'mentions' } ], |
36 | blob: [ { link: id.blob, name: undefined, rel: 'mentions' } ] |
37 | } |
38 | refMention.all = refMention.feed.concat(refMention.msg, refMention.blob) |
39 | |
40 | test('ref mentions are detected', function (t) { |
41 | t.deepEquals(mentions(id.feed), refMention.feed, 'feed link') |
42 | t.deepEquals(mentions(id.blob), refMention.blob, 'blob link') |
43 | t.deepEquals(mentions(id.msg), refMention.msg, 'msg link') |
44 | t.deepEquals(mentions(id.all), refMention.all, 'all link') |
45 | t.end() |
46 | }) |
47 |
Built with git-ssb-web