aboutsummaryrefslogtreecommitdiff
path: root/test/unit/specs/services/entity_normalizer
diff options
context:
space:
mode:
authorHJ <30-hj@users.noreply.git.pleroma.social>2021-09-09 21:51:39 +0000
committerHJ <30-hj@users.noreply.git.pleroma.social>2021-09-09 21:51:39 +0000
commit370f1e55adddd60a22bf56a7782ba61f239eb13c (patch)
tree3a4c897ac420b8d6ab92b31e2779f88947016eed /test/unit/specs/services/entity_normalizer
parentf35e3d0f3fc1a6bb4ebd77fba1dce0ac27f5b7d7 (diff)
parenta8a82ad12f2f7b9eb8fe7a57a3a7d503c6bbe2ed (diff)
Merge branch 'develop' into 'themeApply'
# Conflicts: # CHANGELOG.md
Diffstat (limited to 'test/unit/specs/services/entity_normalizer')
-rw-r--r--test/unit/specs/services/entity_normalizer/entity_normalizer.spec.js83
1 files changed, 1 insertions, 82 deletions
diff --git a/test/unit/specs/services/entity_normalizer/entity_normalizer.spec.js b/test/unit/specs/services/entity_normalizer/entity_normalizer.spec.js
index 759539e0..03fb32c9 100644
--- a/test/unit/specs/services/entity_normalizer/entity_normalizer.spec.js
+++ b/test/unit/specs/services/entity_normalizer/entity_normalizer.spec.js
@@ -1,4 +1,4 @@
-import { parseStatus, parseUser, parseNotification, addEmojis, parseLinkHeaderPagination } from '../../../../../src/services/entity_normalizer/entity_normalizer.service.js'
+import { parseStatus, parseUser, parseNotification, parseLinkHeaderPagination } from '../../../../../src/services/entity_normalizer/entity_normalizer.service.js'
import mastoapidata from '../../../../fixtures/mastoapi.json'
import qvitterapidata from '../../../../fixtures/statuses.json'
@@ -23,7 +23,6 @@ const makeMockStatusQvitter = (overrides = {}) => {
repeat_num: 0,
repeated: false,
statusnet_conversation_id: '16300488',
- statusnet_html: '<p>haha benis</p>',
summary: null,
tags: [],
text: 'haha benis',
@@ -232,22 +231,6 @@ describe('API Entities normalizer', () => {
expect(parsedRepeat).to.have.property('retweeted_status')
expect(parsedRepeat).to.have.deep.property('retweeted_status.id', 'deadbeef')
})
-
- it('adds emojis to post content', () => {
- const post = makeMockStatusMasto({ emojis: makeMockEmojiMasto(), content: 'Makes you think :thinking:' })
-
- const parsedPost = parseStatus(post)
-
- expect(parsedPost).to.have.property('statusnet_html').that.contains('<img')
- })
-
- it('adds emojis to subject line', () => {
- const post = makeMockStatusMasto({ emojis: makeMockEmojiMasto(), spoiler_text: 'CW: 300 IQ :thinking:' })
-
- const parsedPost = parseStatus(post)
-
- expect(parsedPost).to.have.property('summary_html').that.contains('<img')
- })
})
})
@@ -261,35 +244,6 @@ describe('API Entities normalizer', () => {
expect(parseUser(remote)).to.have.property('is_local', false)
})
- it('adds emojis to user name', () => {
- const user = makeMockUserMasto({ emojis: makeMockEmojiMasto(), display_name: 'The :thinking: thinker' })
-
- const parsedUser = parseUser(user)
-
- expect(parsedUser).to.have.property('name_html').that.contains('<img')
- })
-
- it('adds emojis to user bio', () => {
- const user = makeMockUserMasto({ emojis: makeMockEmojiMasto(), note: 'Hello i like to :thinking: a lot' })
-
- const parsedUser = parseUser(user)
-
- expect(parsedUser).to.have.property('description_html').that.contains('<img')
- })
-
- it('adds emojis to user profile fields', () => {
- const user = makeMockUserMasto({ emojis: makeMockEmojiMasto(), fields: [{ name: ':thinking:', value: ':image:' }] })
-
- const parsedUser = parseUser(user)
-
- expect(parsedUser).to.have.property('fields_html').to.be.an('array')
-
- const field = parsedUser.fields_html[0]
-
- expect(field).to.have.property('name').that.contains('<img')
- expect(field).to.have.property('value').that.contains('<img')
- })
-
it('removes html tags from user profile fields', () => {
const user = makeMockUserMasto({ emojis: makeMockEmojiMasto(), fields: [{ name: 'user', value: '<a rel="me" href="https://example.com/@user">@user</a>' }] })
@@ -355,41 +309,6 @@ describe('API Entities normalizer', () => {
})
})
- describe('MastoAPI emoji adder', () => {
- const emojis = makeMockEmojiMasto()
- const imageHtml = '<img src="https://example.com/image.png" alt=":image:" title=":image:" class="emoji" />'
- .replace(/"/g, '\'')
- const thinkHtml = '<img src="https://example.com/think.png" alt=":thinking:" title=":thinking:" class="emoji" />'
- .replace(/"/g, '\'')
-
- it('correctly replaces shortcodes in supplied string', () => {
- const result = addEmojis('This post has :image: emoji and :thinking: emoji', emojis)
- expect(result).to.include(thinkHtml)
- expect(result).to.include(imageHtml)
- })
-
- it('handles consecutive emojis correctly', () => {
- const result = addEmojis('Lelel emoji spam :thinking::thinking::thinking::thinking:', emojis)
- expect(result).to.include(thinkHtml + thinkHtml + thinkHtml + thinkHtml)
- })
-
- it('Doesn\'t replace nonexistent emojis', () => {
- const result = addEmojis('Admin add the :tenshi: emoji', emojis)
- expect(result).to.equal('Admin add the :tenshi: emoji')
- })
-
- it('Doesn\'t blow up on regex special characters', () => {
- const emojis = makeMockEmojiMasto([{
- shortcode: 'c++'
- }, {
- shortcode: '[a-z] {|}*'
- }])
- const result = addEmojis('This post has :c++: emoji and :[a-z] {|}*: emoji', emojis)
- expect(result).to.include('title=\':c++:\'')
- expect(result).to.include('title=\':[a-z] {|}*:\'')
- })
- })
-
describe('Link header pagination', () => {
it('Parses min and max ids as integers', () => {
const linkHeader = '<https://example.com/api/v1/notifications?max_id=861676>; rel="next", <https://example.com/api/v1/notifications?min_id=861741>; rel="prev"'