- {{ emoji }}
+ {{ emoji[0] }}
{{ text }}
diff --git a/src/components/__tests__/helpers.spec.ts b/src/components/__tests__/helpers.spec.ts
index 431380f..d8ecee4 100644
--- a/src/components/__tests__/helpers.spec.ts
+++ b/src/components/__tests__/helpers.spec.ts
@@ -1,8 +1,9 @@
import {describe, it, expect} from 'vitest';
import {DateTime} from 'luxon';
import {ALL_VEGGIES} from '@/utils/constants';
-import {dateParser, getCategoryForVeggie, getRandomVeggie} from '@/utils/helpers';
+import {dateParser, getCategoryForVeggie, getRandomEmojis, getRandomVeggie} from '@/utils/helpers';
import {Category, type Challenge} from '@/utils/types';
+import {unique} from 'remeda';
describe('helpers', () => {
it('returns correct veggie categories', () => {
@@ -35,4 +36,9 @@ describe('helpers', () => {
const parsed: {foo: number; bar: number} = JSON.parse('{"foo": 1, "bar": 2}', dateParser);
expect(parsed).toEqual({foo: 1, bar: 2});
});
+
+ it('gives unique emojis', () => {
+ const emojis = getRandomEmojis(15);
+ expect(unique(emojis)).toHaveLength(15);
+ });
});
diff --git a/src/utils/helpers.ts b/src/utils/helpers.ts
index 71e4850..888efcc 100644
--- a/src/utils/helpers.ts
+++ b/src/utils/helpers.ts
@@ -112,3 +112,47 @@ export const dateParser = (key: string, value: any) => {
}
return value;
};
+
+const veggieEmojis = [
+ '🥝',
+ '🥥',
+ '🍇',
+ '🍈',
+ '🍉',
+ '🍊',
+ '🍋',
+ '🍌',
+ '🍍',
+ '🥭',
+ '🍎',
+ '🍏',
+ '🍐',
+ '🍑',
+ '🍒',
+ '🍓',
+ '🫐',
+ '🍅',
+ '🍆',
+ '🌽',
+ '🌶️',
+ '🫑',
+ '🥑',
+ '🥒',
+ '🥬',
+ '🥦',
+ '🥔',
+ '🧄',
+ '🧅',
+ '🥕',
+ '🫛',
+ '🥜',
+ '🫘',
+ '🌿',
+];
+export const getRandomEmojis = (amount: number = 1) => {
+ const emojis = new Set
();
+ while (emojis.size < amount) {
+ emojis.add(veggieEmojis[Math.floor(Math.random() * veggieEmojis.length)]);
+ }
+ return Array.from(emojis);
+};