♻️ (eta) create an ETA component

This commit is contained in:
Julien Calixte
2023-04-16 09:32:20 +02:00
parent 0b1ff131d7
commit 6b2fba18b1
3 changed files with 41 additions and 0 deletions

View File

@@ -1,6 +1,7 @@
{
"patterns": {
"**/*.vue": "https://vuejs.org/guide/introduction.html",
"**/*.test.ts": "https://v1.test-utils.vuejs.org/guides",
"**/*.store.ts": "https://pinia.vuejs.org/introduction.html",
"**/router/*.ts": "https://router.vuejs.org/"
}

View File

@@ -0,0 +1,23 @@
import { mount } from '@vue/test-utils'
import { describe, expect, it } from 'vitest'
import EstimationTimeArrival from './EstimationTimeArrival.vue'
describe('Estimation Time Arrival', () => {
it('renders an ETA tag and the estimation', () => {
const wrapper = mount(EstimationTimeArrival, {
props: {
estimation: 4
}
})
expect(wrapper.get('.tags')).toBeDefined()
const tags = wrapper.findAll('.tag')
expect(tags.length).toBe(2)
const [eta, label] = tags
expect(eta.text()).toEqual('ETA')
expect(label.text()).toEqual('4 minutes')
})
})

View File

@@ -0,0 +1,17 @@
<script setup lang="ts">
import { computed } from 'vue'
const props = defineProps<{
estimation: number
}>()
const label = computed(() => `${props.estimation} minutes`)
</script>
<template>
<div class="estimation-time-arrival tags has-addons">
<div class="tag">ETA</div>
<div class="tag is-primary" data-test="tag-label">
{{ label }}
</div>
</div>
</template>