2020-10-13 05:08:27 -04:00
|
|
|
|
import MockAdapter from 'axios-mock-adapter';
|
|
|
|
|
import { initEmojiMap, EMOJI_VERSION } from '~/emoji';
|
2021-02-14 13:09:20 -05:00
|
|
|
|
import axios from '~/lib/utils/axios_utils';
|
2020-10-13 05:08:27 -04:00
|
|
|
|
|
|
|
|
|
export const emojiFixtureMap = {
|
|
|
|
|
atom: {
|
|
|
|
|
moji: '⚛',
|
|
|
|
|
description: 'atom symbol',
|
|
|
|
|
unicodeVersion: '4.1',
|
|
|
|
|
aliases: ['atom_symbol'],
|
|
|
|
|
},
|
|
|
|
|
bomb: {
|
|
|
|
|
moji: '💣',
|
|
|
|
|
unicodeVersion: '6.0',
|
|
|
|
|
description: 'bomb',
|
|
|
|
|
},
|
|
|
|
|
construction_worker_tone5: {
|
|
|
|
|
moji: '👷🏿',
|
|
|
|
|
unicodeVersion: '8.0',
|
|
|
|
|
description: 'construction worker tone 5',
|
|
|
|
|
},
|
|
|
|
|
five: {
|
|
|
|
|
moji: '5️⃣',
|
|
|
|
|
unicodeVersion: '3.0',
|
|
|
|
|
description: 'keycap digit five',
|
|
|
|
|
},
|
|
|
|
|
grey_question: {
|
|
|
|
|
moji: '❔',
|
|
|
|
|
unicodeVersion: '6.0',
|
|
|
|
|
description: 'white question mark ornament',
|
2020-10-14 11:08:42 -04:00
|
|
|
|
},
|
|
|
|
|
black_heart: {
|
|
|
|
|
moji: '🖤',
|
|
|
|
|
unicodeVersion: '1.1',
|
|
|
|
|
description: 'black heart',
|
|
|
|
|
},
|
|
|
|
|
heart: {
|
|
|
|
|
moji: '❤',
|
|
|
|
|
unicodeVersion: '1.1',
|
|
|
|
|
description: 'heavy black heart',
|
|
|
|
|
},
|
|
|
|
|
custard: {
|
|
|
|
|
moji: '🍮',
|
|
|
|
|
unicodeVersion: '6.0',
|
|
|
|
|
description: 'custard',
|
|
|
|
|
},
|
|
|
|
|
star: {
|
|
|
|
|
moji: '⭐',
|
|
|
|
|
unicodeVersion: '5.1',
|
|
|
|
|
description: 'white medium star',
|
2020-10-13 05:08:27 -04:00
|
|
|
|
},
|
2021-09-01 05:10:58 -04:00
|
|
|
|
xss: {
|
|
|
|
|
moji: '<img src=x onerror=prompt(1)>',
|
|
|
|
|
unicodeVersion: '5.1',
|
|
|
|
|
description: 'xss',
|
|
|
|
|
},
|
2020-10-13 05:08:27 -04:00
|
|
|
|
};
|
|
|
|
|
|
2021-02-06 04:09:11 -05:00
|
|
|
|
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 };
|
2020-10-14 11:08:42 -04:00
|
|
|
|
|
2021-02-06 04:09:11 -05:00
|
|
|
|
return acc;
|
|
|
|
|
}, {});
|
2020-10-13 05:08:27 -04:00
|
|
|
|
|
2021-02-06 04:09:11 -05:00
|
|
|
|
export async function initEmojiMock(mockData = mockEmojiData) {
|
2020-10-13 05:08:27 -04:00
|
|
|
|
const mock = new MockAdapter(axios);
|
2021-02-06 04:09:11 -05:00
|
|
|
|
mock.onGet(`/-/emojis/${EMOJI_VERSION}/emojis.json`).reply(200, JSON.stringify(mockData));
|
2020-10-13 05:08:27 -04:00
|
|
|
|
|
|
|
|
|
await initEmojiMap();
|
|
|
|
|
|
|
|
|
|
return mock;
|
|
|
|
|
}
|