From 7f3ab20555d303fbfe34a4569f86421e065e89d8 Mon Sep 17 00:00:00 2001 From: Alex Gleason Date: Tue, 15 Nov 2022 10:22:43 -0600 Subject: [PATCH] Fix tests that rely on emojification --- app/soapbox/normalizers/__tests__/account.test.ts | 10 ++++------ app/soapbox/normalizers/__tests__/poll.test.ts | 2 +- app/soapbox/normalizers/__tests__/status.test.ts | 2 +- app/soapbox/reducers/__tests__/statuses.test.ts | 2 +- 4 files changed, 7 insertions(+), 9 deletions(-) diff --git a/app/soapbox/normalizers/__tests__/account.test.ts b/app/soapbox/normalizers/__tests__/account.test.ts index b5f4f5a75..846c6f471 100644 --- a/app/soapbox/normalizers/__tests__/account.test.ts +++ b/app/soapbox/normalizers/__tests__/account.test.ts @@ -131,15 +131,13 @@ describe('normalizeAccount()', () => { it('emojifies display name as `display_name_html`', () => { const account = require('soapbox/__fixtures__/account-with-emojis.json'); const result = normalizeAccount(account); - const expected = 'Alex Gleason 😂 :soapbox: :ablobcatrainbow:'; - expect(result.display_name_html).toBe(expected); + expect(result.display_name_html).toContain('emojione'); }); it('emojifies note as `note_emojified`', () => { const account = require('soapbox/__fixtures__/account-with-emojis.json'); const result = normalizeAccount(account); - const expected = 'I create Fediverse software that empowers people online. :soapbox:

I'm vegan btw

Note: If you have a question for me, please tag me publicly. This gives the opportunity for others to chime in, and bystanders to learn.'; - expect(result.note_emojified).toBe(expected); + expect(result.note_emojified).toContain('emojione'); }); it('unescapes HTML note as `note_plain`', () => { @@ -154,8 +152,8 @@ describe('normalizeAccount()', () => { const result = normalizeAccount(account); const field = result.fields.get(1); - expect(field?.name_emojified).toBe('Soapbox :ablobcatrainbow:'); - expect(field?.value_emojified).toBe('https://soapbox.pub :soapbox:'); + expect(field?.name_emojified).toContain('emojione'); + expect(field?.value_emojified).toContain('emojione'); expect(field?.value_plain).toBe('https://soapbox.pub :soapbox:'); }); diff --git a/app/soapbox/normalizers/__tests__/poll.test.ts b/app/soapbox/normalizers/__tests__/poll.test.ts index b7ba0a46f..d5226e938 100644 --- a/app/soapbox/normalizers/__tests__/poll.test.ts +++ b/app/soapbox/normalizers/__tests__/poll.test.ts @@ -38,7 +38,7 @@ describe('normalizePoll()', () => { // Emojifies poll options expect(result.options.get(1)?.title_emojified) - .toEqual('Custom emoji :gleason_excited: '); + .toContain('emojione'); // Parses emojis as Immutable.Record's expect(ImmutableRecord.isRecord(result.emojis.get(0))).toBe(true); diff --git a/app/soapbox/normalizers/__tests__/status.test.ts b/app/soapbox/normalizers/__tests__/status.test.ts index b60373975..5ad29d926 100644 --- a/app/soapbox/normalizers/__tests__/status.test.ts +++ b/app/soapbox/normalizers/__tests__/status.test.ts @@ -183,7 +183,7 @@ describe('normalizeStatus()', () => { // Emojifies poll options expect(poll.options.get(1)?.title_emojified) - .toEqual('Custom emoji :gleason_excited: '); + .toContain('emojione'); // Parses emojis as Immutable.Record's expect(ImmutableRecord.isRecord(poll.emojis.get(0))).toBe(true); diff --git a/app/soapbox/reducers/__tests__/statuses.test.ts b/app/soapbox/reducers/__tests__/statuses.test.ts index 06d82c871..1db00ec64 100644 --- a/app/soapbox/reducers/__tests__/statuses.test.ts +++ b/app/soapbox/reducers/__tests__/statuses.test.ts @@ -118,7 +118,7 @@ describe('statuses reducer', () => { const status = require('soapbox/__fixtures__/status-custom-emoji.json'); const action = { type: STATUS_IMPORT, status }; - const expected = 'Hello :ablobcathyper: :ageblobcat: 😂 world 😋 test :blobcatphoto:'; + const expected = 'Hello :ablobcathyper: :ageblobcat: 😂 world 😋 test :blobcatphoto:'; const result = reducer(undefined, action).getIn(['AGm7uC9DaAIGUa4KYK', 'contentHtml']); expect(result).toBe(expected);