♻️ (eta) create an ETA component
This commit is contained in:
23
src/components/EstimationTimeArrival.test.ts
Normal file
23
src/components/EstimationTimeArrival.test.ts
Normal 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')
|
||||
})
|
||||
})
|
||||
17
src/components/EstimationTimeArrival.vue
Normal file
17
src/components/EstimationTimeArrival.vue
Normal 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>
|
||||
Reference in New Issue
Block a user