aboutsummaryrefslogtreecommitdiff
path: root/test/unit/specs/services/mention_matcher/mention_matcher.spec.js
diff options
context:
space:
mode:
authorshpuld <shp@cock.li>2019-01-30 20:49:24 +0200
committershpuld <shp@cock.li>2019-01-30 20:49:24 +0200
commitc7cffbb6c70bbb21cf787d96e82e0261427b9234 (patch)
treea517e4942725286b173b685cbe87bc6c7878b66e /test/unit/specs/services/mention_matcher/mention_matcher.spec.js
parent51024a2c8af9d88b07c050b7502fa62843aa4ba2 (diff)
parentb1facdf7ad54436c2afde7c28c917cda87a5b7e3 (diff)
Merge branch 'develop' into feat/media-modal
Diffstat (limited to 'test/unit/specs/services/mention_matcher/mention_matcher.spec.js')
-rw-r--r--test/unit/specs/services/mention_matcher/mention_matcher.spec.js63
1 files changed, 63 insertions, 0 deletions
diff --git a/test/unit/specs/services/mention_matcher/mention_matcher.spec.js b/test/unit/specs/services/mention_matcher/mention_matcher.spec.js
new file mode 100644
index 00000000..4f6f58ff
--- /dev/null
+++ b/test/unit/specs/services/mention_matcher/mention_matcher.spec.js
@@ -0,0 +1,63 @@
+import * as MentionMatcher from 'src/services/mention_matcher/mention_matcher.js'
+
+const localAttn = () => ({
+ id: 123,
+ is_local: true,
+ name: 'Guy',
+ screen_name: 'person',
+ statusnet_profile_url: 'https://instance.com/users/person'
+})
+
+const externalAttn = () => ({
+ id: 123,
+ is_local: false,
+ name: 'Guy',
+ screen_name: 'person@instance.com',
+ statusnet_profile_url: 'https://instance.com/users/person'
+})
+
+describe('MentionMatcher', () => {
+ describe.only('mentionMatchesUrl', () => {
+ it('should match local mention', () => {
+ const attention = localAttn()
+ const url = 'https://instance.com/users/person'
+
+ expect(MentionMatcher.mentionMatchesUrl(attention, url)).to.eql(true)
+ })
+
+ it('should not match a local mention with same name but different instance', () => {
+ const attention = localAttn()
+ const url = 'https://website.com/users/person'
+
+ expect(MentionMatcher.mentionMatchesUrl(attention, url)).to.eql(false)
+ })
+
+ it('should match external pleroma mention', () => {
+ const attention = externalAttn()
+ const url = 'https://instance.com/users/person'
+
+ expect(MentionMatcher.mentionMatchesUrl(attention, url)).to.eql(true)
+ })
+
+ it('should not match external pleroma mention with same name but different instance', () => {
+ const attention = externalAttn()
+ const url = 'https://website.com/users/person'
+
+ expect(MentionMatcher.mentionMatchesUrl(attention, url)).to.eql(false)
+ })
+
+ it('should match external mastodon mention', () => {
+ const attention = externalAttn()
+ const url = 'https://instance.com/@person'
+
+ expect(MentionMatcher.mentionMatchesUrl(attention, url)).to.eql(true)
+ })
+
+ it('should not match external mastodon mention with same name but different instance', () => {
+ const attention = externalAttn()
+ const url = 'https://website.com/@person'
+
+ expect(MentionMatcher.mentionMatchesUrl(attention, url)).to.eql(false)
+ })
+ })
+})