Files: 3cf12190d9605012c3fa7f7b4f92094c051b371c / test / mentions.js
1719 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 |
Built with git-ssb-web