Skip to content

Commit 7c28437

Browse files
test: add unit tests for server API handlers related to tweets
1 parent 7ef050d commit 7c28437

4 files changed

Lines changed: 508 additions & 1 deletion

File tree

app/pages/playground/tweet.vue

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<script setup lang="ts">
2+
import type { Tweet } from '~~/types/tweets';
3+
const tweets = ref<Tweet[]>([]);
4+
5+
const { data: tweetsData, error } = useFetch<{ data: Tweet[] }>('/api/tweets');
6+
tweets.value = tweetsData.value?.data || [];
7+
8+
if (error.value) console.error(error.value);
9+
</script>
10+
11+
<template>
12+
<div class="p-4">
13+
<h1 v-if="tweets[1]" class="mb-4 text-2xl font-bold">
14+
{{ tweets[1].id }}
15+
</h1>
16+
<h1 v-else>{{ $t('testing.tweets.tweet-not-found') }}</h1>
17+
</div>
18+
</template>

i18n/locales/ar.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,10 @@
1010
"follow": "متابعة",
1111
"unfollow": "إلغاء المتابعة",
1212
"following": "متابع",
13-
"subscribe": "الاشتراك"
13+
"subscribe": "الاشتراك",
14+
"tweets": {
15+
"tweet-not-found": "التغريدة غير موجودة"
16+
}
1417
},
1518
"root": {
1619
"hero": {

i18n/locales/en.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@
1010
"user": {
1111
"name": "John Doe",
1212
"username": "johndoe"
13+
},
14+
"tweets": {
15+
"tweet-not-found": "Tweet not found"
1316
}
1417
},
1518
"root": {

0 commit comments

Comments
 (0)