diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-02-18 10:34:06 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-02-18 10:34:06 +0000 |
commit | 859a6fb938bb9ee2a317c46dfa4fcc1af49608f0 (patch) | |
tree | d7f2700abe6b4ffcb2dcfc80631b2d87d0609239 /spec/frontend/__helpers__/emoji.js | |
parent | 446d496a6d000c73a304be52587cd9bbc7493136 (diff) | |
download | gitlab-ce-859a6fb938bb9ee2a317c46dfa4fcc1af49608f0.tar.gz |
Add latest changes from gitlab-org/gitlab@13-9-stable-eev13.9.0-rc42
Diffstat (limited to 'spec/frontend/__helpers__/emoji.js')
-rw-r--r-- | spec/frontend/__helpers__/emoji.js | 36 |
1 files changed, 8 insertions, 28 deletions
diff --git a/spec/frontend/__helpers__/emoji.js b/spec/frontend/__helpers__/emoji.js index ea6613b53c9..9f9134f6f63 100644 --- a/spec/frontend/__helpers__/emoji.js +++ b/spec/frontend/__helpers__/emoji.js @@ -1,6 +1,6 @@ import MockAdapter from 'axios-mock-adapter'; -import axios from '~/lib/utils/axios_utils'; import { initEmojiMap, EMOJI_VERSION } from '~/emoji'; +import axios from '~/lib/utils/axios_utils'; export const emojiFixtureMap = { atom: { @@ -29,10 +29,6 @@ export const emojiFixtureMap = { unicodeVersion: '6.0', description: 'white question mark ornament', }, - - // used for regression tests - // black_heart MUST come before heart - // custard MUST come before star black_heart: { moji: '🖤', unicodeVersion: '1.1', @@ -55,34 +51,18 @@ export const emojiFixtureMap = { }, }; -Object.keys(emojiFixtureMap).forEach((k) => { - emojiFixtureMap[k].name = k; - if (!emojiFixtureMap[k].aliases) { - emojiFixtureMap[k].aliases = []; - } -}); +export const mockEmojiData = Object.keys(emojiFixtureMap).reduce((acc, k) => { + const { moji: e, unicodeVersion: u, category: c, description: d } = emojiFixtureMap[k]; + acc[k] = { name: k, e, u, c, d }; -export async function initEmojiMock() { - const emojiData = Object.fromEntries( - Object.values(emojiFixtureMap).map((m) => { - const { name: n, moji: e, unicodeVersion: u, category: c, description: d } = m; - return [n, { c, e, d, u }]; - }), - ); + return acc; +}, {}); +export async function initEmojiMock(mockData = mockEmojiData) { const mock = new MockAdapter(axios); - mock.onGet(`/-/emojis/${EMOJI_VERSION}/emojis.json`).reply(200, JSON.stringify(emojiData)); + mock.onGet(`/-/emojis/${EMOJI_VERSION}/emojis.json`).reply(200, JSON.stringify(mockData)); await initEmojiMap(); return mock; } - -export function describeEmojiFields(label, tests) { - describe.each` - field | accessor - ${'name'} | ${(e) => e.name} - ${'alias'} | ${(e) => e.aliases[0]} - ${'description'} | ${(e) => e.description} - `(label, tests); -} |