2022-11-15 09:36:54 +01:00
|
|
|
import { describe, it, expect } from 'vitest'
|
2021-01-27 13:24:23 +01:00
|
|
|
import { setup } from '../helpers'
|
|
|
|
import { mdiChevronDown } from '@mdi/js'
|
2022-11-15 09:36:54 +01:00
|
|
|
import SpeedCard from '@/components/Core/SpeedCard.vue'
|
2021-01-27 13:24:23 +01:00
|
|
|
|
|
|
|
describe('SpeedCard.vue', () => {
|
|
|
|
it('should render the card', () => {
|
|
|
|
const wrapper = setup(SpeedCard)
|
|
|
|
expect(wrapper.find('[data-testid="SpeedCard"]').exists()).toBe(true)
|
|
|
|
})
|
|
|
|
|
2022-11-15 09:36:54 +01:00
|
|
|
it("shouldn't render the icon", () => {
|
2021-01-27 13:24:23 +01:00
|
|
|
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 11:42:20 +01:00
|
|
|
it('should render with 0 as value', () => {
|
|
|
|
const wrapper = setup(SpeedCard)
|
2021-01-27 13:24:23 +01:00
|
|
|
expect(wrapper.find('[data-testid="SpeedCard-value"]').exists()).toBe(true)
|
2021-01-29 11:42:20 +01:00
|
|
|
expect(wrapper.find('[data-testid="SpeedCard-value"]').text()).toBe('0')
|
2021-01-27 13:24:23 +01:00
|
|
|
|
|
|
|
expect(wrapper.find('[data-testid="SpeedCard-unit"]').exists()).toBe(true)
|
2021-01-29 11:42:20 +01: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 13:24:23 +01:00
|
|
|
expect(wrapper.find('[data-testid="SpeedCard-unit"]').text()).toBe('KB/s')
|
|
|
|
})
|
2021-01-29 11:42:20 +01:00
|
|
|
|
2021-02-15 08:40:57 +01:00
|
|
|
it('should render value (1 decimals) and unit & be formatted', () => {
|
2021-01-29 11:42:20 +01:00
|
|
|
const wrapper = setup(SpeedCard, { value: 10899700 })
|
2021-02-15 08:40:57 +01:00
|
|
|
expect(wrapper.find('[data-testid="SpeedCard-value"]').text()).toBe('10.4')
|
2021-01-29 11:42:20 +01:00
|
|
|
|
|
|
|
expect(wrapper.find('[data-testid="SpeedCard-unit"]').text()).toBe('MB/s')
|
|
|
|
})
|
2021-02-15 08:40:57 +01:00
|
|
|
})
|