Skip to content

Commit

Permalink
Add tests for breadcrumb component
Browse files Browse the repository at this point in the history
  • Loading branch information
Ruhshan committed Aug 24, 2024
1 parent 38e1395 commit 6496827
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 7 deletions.
6 changes: 1 addition & 5 deletions frontend-vue3/src/components/BreadCrumb.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<script setup lang="ts">
import {ref} from "vue";
import { ref } from 'vue'
interface Props {
title: string
Expand All @@ -27,7 +26,6 @@ const breadCrumbItems = ref<BreadCrumbItem[]>([
href: ''
}
])
</script>

<template>
Expand All @@ -41,5 +39,3 @@ const breadCrumbItems = ref<BreadCrumbItem[]>([
</v-container>
</div>
</template>

<style scoped></style>
38 changes: 38 additions & 0 deletions frontend-vue3/src/components/__tests__/BreadCrumb.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import { describe, it, expect } from 'vitest'
import { mount } from '@vue/test-utils'

import BreadCrumb from '../BreadCrumb.vue'
import { createVuetify } from 'vuetify'
import * as components from 'vuetify/components'
import * as directives from 'vuetify/directives'

const vuetify = createVuetify({
components,
directives
})

describe('BreadCrumb.vue', () => {
const wrapper = mount(BreadCrumb, {
global: {
plugins: [vuetify]
},
propsData: {
title: 'TITLE',
itemName: 'ItemName'
}
})

it('renders the breadcrumb title correctly', async () => {
const title = wrapper.get('.v-breadcrumbs__prepend h2').text()

expect(title).toBe('TITLE')
})

it('renders the breadcrumb items correctly', async () => {
const breadCrumbItems = wrapper.findAllComponents('.v-breadcrumbs-item')

expect(breadCrumbItems).length(2)
expect(breadCrumbItems[0].text()).toBe('Home')
expect(breadCrumbItems[1].text()).toBe('ItemName')
})
})
2 changes: 0 additions & 2 deletions frontend-vue3/src/views/GuideView.vue
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
<script setup lang="ts">
import BreadCrumb from '@/components/BreadCrumb.vue'
</script>

<template>
Expand Down

0 comments on commit 6496827

Please sign in to comment.