Files: 27b98ddcb4a61a15e2b1b237e0ead0de6cd87798 / test / mentions.js
2188 bytesRaw
1 | var test = require('tape') |
2 | var mentions = require('../') |
3 | |
4 | test('mentions in links are detected', function (t) { |
5 | t.deepEquals(mentions( |
6 | '[@feed](@3HO6R2i60XNR3h6XCHAWCdt1k9Dwy+gaa2rVs6LzZ6Y=.ed25519)'), [ |
7 | { |
8 | link: '@3HO6R2i60XNR3h6XCHAWCdt1k9Dwy+gaa2rVs6LzZ6Y=.ed25519', |
9 | name: 'feed', |
10 | } |
11 | ], 'feed link') |
12 | |
13 | t.deepEquals(mentions( |
14 | '[a msg](%A2LvseOYKDXyuSGlXl3Sz0F5j2khVCN6JTf8ORD/tM8=.sha256)'), [ |
15 | { |
16 | link: '%A2LvseOYKDXyuSGlXl3Sz0F5j2khVCN6JTf8ORD/tM8=.sha256', |
17 | name: 'a msg', |
18 | } |
19 | ], 'msg link') |
20 | |
21 | t.deepEquals(mentions( |
22 | '[a blob](&9SSTQys34p9f4zqjxvRwENjFX0JapgtesRey7+fxK14=.sha256)'), [ |
23 | { |
24 | link: '&9SSTQys34p9f4zqjxvRwENjFX0JapgtesRey7+fxK14=.sha256', |
25 | name: 'a blob', |
26 | } |
27 | ], 'blob link') |
28 | |
29 | t.end() |
30 | }) |
31 | |
32 | test('ref mentions are detected', function (t) { |
33 | t.deepEquals(mentions( |
34 | '@3HO6R2i60XNR3h6XCHAWCdt1k9Dwy+gaa2rVs6LzZ6Y=.ed25519'), [ |
35 | { |
36 | link: '@3HO6R2i60XNR3h6XCHAWCdt1k9Dwy+gaa2rVs6LzZ6Y=.ed25519', |
37 | name: undefined |
38 | } |
39 | ], 'feed link') |
40 | |
41 | t.deepEquals(mentions( |
42 | '%A2LvseOYKDXyuSGlXl3Sz0F5j2khVCN6JTf8ORD/tM8=.sha256'), [ |
43 | { |
44 | link: '%A2LvseOYKDXyuSGlXl3Sz0F5j2khVCN6JTf8ORD/tM8=.sha256', |
45 | name: undefined |
46 | } |
47 | ], 'msg link') |
48 | |
49 | t.deepEquals(mentions( |
50 | '&9SSTQys34p9f4zqjxvRwENjFX0JapgtesRey7+fxK14=.sha256'), [ |
51 | { |
52 | link: '&9SSTQys34p9f4zqjxvRwENjFX0JapgtesRey7+fxK14=.sha256', |
53 | name: undefined |
54 | } |
55 | ], 'blob link') |
56 | |
57 | t.end() |
58 | }) |
59 | |
60 | test('bare feed name mentions can be detected', function (t) { |
61 | t.deepEquals(mentions('a @feed mention', {bareFeedNames: true}), |
62 | [{name: 'feed', link: '@'}], 'feed link') |
63 | t.end() |
64 | }) |
65 | |
66 | test('detect hashtags', function (t) { |
67 | t.deepEquals(mentions('a nice #hashtag here'), |
68 | [{link: '#hashtag'}], 'hashtag link') |
69 | t.end() |
70 | }) |
71 | |
72 | test('no html tags in link names', function (t) { |
73 | t.deepEquals(mentions('link: [`code` *em* **strong** ~~del~~]' + |
74 | '(&9SSTQys34p9f4zqjxvRwENjFX0JapgtesRey7+fxK14=.sha256)'), [ |
75 | { |
76 | link: '&9SSTQys34p9f4zqjxvRwENjFX0JapgtesRey7+fxK14=.sha256', |
77 | name: 'code em strong del' |
78 | } |
79 | ], 'no tags') |
80 | t.end() |
81 | }) |
82 |
Built with git-ssb-web