summaryrefslogtreecommitdiff
path: root/spec/frontend/emoji
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-10-16 12:09:33 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2020-10-16 12:09:33 +0000
commit3775eba7c1d41443461e3abcdab2867bbc4636ae (patch)
tree4c1ed52aa0dd296c1608e2d1d6911e86cdf29abf /spec/frontend/emoji
parented7568cc8083a9f8923d1a26bc0d8f60e3f629a3 (diff)
downloadgitlab-ce-3775eba7c1d41443461e3abcdab2867bbc4636ae.tar.gz
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/frontend/emoji')
-rw-r--r--spec/frontend/emoji/emoji_spec.js28
1 files changed, 25 insertions, 3 deletions
diff --git a/spec/frontend/emoji/emoji_spec.js b/spec/frontend/emoji/emoji_spec.js
index 35cf3a62fff..f528313ef02 100644
--- a/spec/frontend/emoji/emoji_spec.js
+++ b/spec/frontend/emoji/emoji_spec.js
@@ -1,6 +1,6 @@
import { trimText } from 'helpers/text_helper';
import { emojiFixtureMap, initEmojiMock, describeEmojiFields } from 'helpers/emoji';
-import { glEmojiTag, searchEmoji } from '~/emoji';
+import { glEmojiTag, searchEmoji, getEmoji } from '~/emoji';
import isEmojiUnicodeSupported, {
isFlagEmoji,
isRainbowFlagEmoji,
@@ -352,6 +352,20 @@ describe('gl_emoji', () => {
});
});
+ describe('getEmoji', () => {
+ const { grey_question } = emojiFixtureMap;
+
+ describe('when query is undefined', () => {
+ it('should return null by default', () => {
+ expect(getEmoji()).toBe(null);
+ });
+
+ it('should return fallback emoji when fallback is true', () => {
+ expect(getEmoji(undefined, true).name).toEqual(grey_question.name);
+ });
+ });
+ });
+
describe('searchEmoji', () => {
const { atom, grey_question } = emojiFixtureMap;
const search = (query, opts) => searchEmoji(query, opts).map(({ name }) => name);
@@ -382,6 +396,10 @@ describe('gl_emoji', () => {
it('should not return a fallback value', () => {
expect(subject('foo bar baz')).toHaveLength(0);
});
+
+ it('should not return a fallback value when query is falsey', () => {
+ expect(subject()).toHaveLength(0);
+ });
});
describe('with fuzzy match', () => {
@@ -427,8 +445,12 @@ describe('gl_emoji', () => {
describe('with fallback', () => {
const subject = query => search(query, { fallback: true });
- it('should return a fallback value', () =>
- expect(subject('foo bar baz')).toContain(grey_question.name));
+ it.each`
+ query
+ ${'foo bar baz'} | ${undefined}
+ `('should return a fallback value when given $query', ({ query }) => {
+ expect(subject(query)).toContain(grey_question.name);
+ });
});
describe('with name and alias fields', () => {