VueTorrent/tests/unit/SpeedCard.spec.js

44 lines
1.6 KiB
JavaScript
Raw Normal View History

2021-01-27 15:24:23 +03:00
import { setup } from '../helpers'
import SpeedCard from '@/components/Core/SpeedCard.vue'
import { mdiChevronDown } from '@mdi/js'
describe('SpeedCard.vue', () => {
it('should render the card', () => {
const wrapper = setup(SpeedCard)
expect(wrapper.find('[data-testid="SpeedCard"]').exists()).toBe(true)
})
it('shouldn\'t render the icon', () => {
const wrapper = setup(SpeedCard)
expect(wrapper.find('[data-testid="SpeedCard-icon"]').exists()).toBe(false)
})
it('should render the icon', () => {
const wrapper = setup(SpeedCard, { icon: mdiChevronDown })
expect(wrapper.find('[data-testid="SpeedCard-icon"]').exists()).toBe(true)
})
2021-01-29 13:42:20 +03:00
it('should render with 0 as value', () => {
const wrapper = setup(SpeedCard)
2021-01-27 15:24:23 +03:00
expect(wrapper.find('[data-testid="SpeedCard-value"]').exists()).toBe(true)
2021-01-29 13:42:20 +03:00
expect(wrapper.find('[data-testid="SpeedCard-value"]').text()).toBe('0')
2021-01-27 15:24:23 +03:00
expect(wrapper.find('[data-testid="SpeedCard-unit"]').exists()).toBe(true)
2021-01-29 13:42:20 +03:00
expect(wrapper.find('[data-testid="SpeedCard-unit"]').text()).toBe('B/s')
})
it('should render value (0 decimals) and unit & be formatted', () => {
const wrapper = setup(SpeedCard, { value: 26823 })
expect(wrapper.find('[data-testid="SpeedCard-value"]').text()).toBe('26')
2021-01-27 15:24:23 +03:00
expect(wrapper.find('[data-testid="SpeedCard-unit"]').text()).toBe('KB/s')
})
2021-01-29 13:42:20 +03:00
2021-02-15 10:40:57 +03:00
it('should render value (1 decimals) and unit & be formatted', () => {
2021-01-29 13:42:20 +03:00
const wrapper = setup(SpeedCard, { value: 10899700 })
2021-02-15 10:40:57 +03:00
expect(wrapper.find('[data-testid="SpeedCard-value"]').text()).toBe('10.4')
2021-01-29 13:42:20 +03:00
expect(wrapper.find('[data-testid="SpeedCard-unit"]').text()).toBe('MB/s')
})
2021-02-15 10:40:57 +03:00
})