diff options
Diffstat (limited to 'spec/frontend/emoji')
-rw-r--r-- | spec/frontend/emoji/index_spec.js | 13 | ||||
-rw-r--r-- | spec/frontend/emoji/support/unicode_support_map_spec.js | 6 |
2 files changed, 15 insertions, 4 deletions
diff --git a/spec/frontend/emoji/index_spec.js b/spec/frontend/emoji/index_spec.js index 1e6f5483160..9652c513671 100644 --- a/spec/frontend/emoji/index_spec.js +++ b/spec/frontend/emoji/index_spec.js @@ -9,6 +9,7 @@ import isEmojiUnicodeSupported, { isHorceRacingSkinToneComboEmoji, isPersonZwjEmoji, } from '~/emoji/support/is_emoji_unicode_supported'; +import { sanitize } from '~/lib/dompurify'; const emptySupportMap = { personZwj: false, @@ -379,7 +380,7 @@ describe('emoji', () => { describe('searchEmoji', () => { const emojiFixture = Object.keys(mockEmojiData).reduce((acc, k) => { const { name, e, u, d } = mockEmojiData[k]; - acc[k] = { name, e, u, d }; + acc[k] = { name, e: sanitize(e), u, d }; return acc; }, {}); @@ -397,6 +398,7 @@ describe('emoji', () => { 'heart', 'custard', 'star', + 'xss', ].map((name) => { return { emoji: emojiFixture[name], @@ -620,4 +622,13 @@ describe('emoji', () => { expect(sortEmoji(scoredItems)).toEqual(expected); }); }); + + describe('sanitize emojis', () => { + it('should return sanitized emoji', () => { + expect(getEmojiInfo('xss')).toEqual({ + ...mockEmojiData.xss, + e: '<img src="x">', + }); + }); + }); }); diff --git a/spec/frontend/emoji/support/unicode_support_map_spec.js b/spec/frontend/emoji/support/unicode_support_map_spec.js index 945e804a9fa..37f74db30b5 100644 --- a/spec/frontend/emoji/support/unicode_support_map_spec.js +++ b/spec/frontend/emoji/support/unicode_support_map_spec.js @@ -8,14 +8,14 @@ describe('Unicode Support Map', () => { const stringSupportMap = 'stringSupportMap'; beforeEach(() => { - jest.spyOn(AccessorUtilities, 'isLocalStorageAccessSafe').mockImplementation(() => {}); + jest.spyOn(AccessorUtilities, 'canUseLocalStorage').mockImplementation(() => {}); jest.spyOn(JSON, 'parse').mockImplementation(() => {}); jest.spyOn(JSON, 'stringify').mockReturnValue(stringSupportMap); }); describe('if isLocalStorageAvailable is `true`', () => { beforeEach(() => { - jest.spyOn(AccessorUtilities, 'isLocalStorageAccessSafe').mockReturnValue(true); + jest.spyOn(AccessorUtilities, 'canUseLocalStorage').mockReturnValue(true); getUnicodeSupportMap(); }); @@ -38,7 +38,7 @@ describe('Unicode Support Map', () => { describe('if isLocalStorageAvailable is `false`', () => { beforeEach(() => { - jest.spyOn(AccessorUtilities, 'isLocalStorageAccessSafe').mockReturnValue(false); + jest.spyOn(AccessorUtilities, 'canUseLocalStorage').mockReturnValue(false); getUnicodeSupportMap(); }); |