1
0
Fork 0
mirror of https://github.com/VueTorrent/VueTorrent.git synced 2025-03-24 02:20:44 +03:00
VueTorrent/tests/unit/StorageCard.spec.js

44 lines
1.4 KiB
JavaScript
Raw Normal View History

2023-07-20 13:50:46 +02:00
import { describe, beforeEach, it, expect, vi } from 'vitest'
import { shallowMount } from '@vue/test-utils'
import StorageCard from '@/components/Core/StorageCard.vue'
2021-01-27 13:24:23 +01:00
2023-07-20 13:50:46 +02:00
const label = 'Downloaded'
const value = 10000
const color = 'download'
let wrapper
2021-01-27 13:24:23 +01:00
describe('StorageCard.vue', () => {
2023-07-20 13:50:46 +02:00
beforeEach(() => {
wrapper = shallowMount(StorageCard, {
2023-07-22 22:20:33 +02:00
propsData: { label, value, color },
2023-07-20 13:50:46 +02:00
filters: {
formatDataValue: vi.fn().mockReturnValue('9.77'),
formatDataUnit: vi.fn().mockReturnValue('KB')
},
mocks: {
$store: {
2023-07-22 22:20:33 +02:00
getters: { shouldUseBinaryData: vi.fn().mockReturnValue(true) }
2023-07-20 13:50:46 +02:00
}
}
})
})
2021-01-27 13:24:23 +01:00
it('should render the label', () => {
expect(wrapper.find('[data-testid="StorageCard-label"]').text()).toEqual(label)
})
it('should render value and unit & be formatted', () => {
expect(wrapper.find('[data-testid="StorageCard-value"]').exists()).toBe(true)
expect(wrapper.find('[data-testid="StorageCard-value"]').text()).toBe('9.77')
expect(wrapper.find('[data-testid="StorageCard-unit"]').exists()).toBe(true)
expect(wrapper.find('[data-testid="StorageCard-unit"]').text()).toBe('KB')
})
it('text should have the passed-in color', () => {
expect(wrapper.find('[data-testid="StorageCard-label"]').classes()).toContain(color + '--text')
expect(wrapper.find('[data-testid="StorageCard-Wrapper"]').classes()).toContain(color + '--text')
})
})