--spacing-sm: 0.25rem;
--spacing-md: 0.5rem;
--spacing-lg: 1rem;
- --spacing-xl: 1.5rem;
/* Typography */
--font-family: Tahoma, 'Arial Narrow', Arial, Helvetica, sans-serif;
--spacing-sm: 0.25rem;
--spacing-md: 0.5rem;
--spacing-lg: 1rem;
- --spacing-xl: 1.5rem;
/* Typography */
--font-family: Tahoma, 'Arial Narrow', Arial, Helvetica, sans-serif;
--spacing-sm: 0.25rem;
--spacing-md: 0.5rem;
--spacing-lg: 1rem;
- --spacing-xl: 1.5rem;
/* Typography */
--font-family: Tahoma, 'Arial Narrow', Arial, Helvetica, sans-serif;
+++ /dev/null
-<template>
- <Button>
- <span :class="{ spin: loading }"> ↻ </span>
- </Button>
-</template>
-
-<script setup lang="ts">
-import Button from '@/components/buttons/Button.vue'
-
-defineProps<{
- loading: boolean
-}>()
-</script>
-
-<style scoped>
-@keyframes spin {
- from {
- transform: rotate(0deg);
- }
- to {
- transform: rotate(360deg);
- }
-}
-
-.spin {
- animation: spin 2s linear infinite;
-}
-</style>
>
Add Charging Stations
</ToggleButton>
- <ReloadButton
- class="reload-button"
- :loading="state.gettingChargingStations"
- @click="getChargingStations()"
- />
</Container>
<CSTable
v-show="Array.isArray($chargingStations) && $chargingStations.length > 0"
:key="state.renderChargingStations"
:charging-stations="$chargingStations"
- @need-refresh="
- () => {
- getChargingStations()
- state.renderAddChargingStations = randomUUID()
- state.renderChargingStations = randomUUID()
- }
- "
+ @need-refresh="() => { state.renderAddChargingStations = randomUUID() }"
/>
</Container>
</template>
UUIDv4,
} from '@/types'
-import ReloadButton from '@/components/buttons/ReloadButton.vue'
import StateButton from '@/components/buttons/StateButton.vue'
import ToggleButton from '@/components/buttons/ToggleButton.vue'
import CSTable from '@/components/charging-stations/CSTable.vue'
.buttons-container > * {
flex: 1 1 0;
}
-
-.reload-button {
- font-size: 1.5rem;
-}
-
-.reload-button:active {
- background-color: var(--color-primary);
-}
</style>
stubs: {
Container: { name: 'Container', template: '<div><slot /></div>' },
CSTable: true,
- ReloadButton: {
- emits: ['click'],
- name: 'ReloadButton',
- props: ['loading'],
- template: '<button @click="$emit(\'click\')" />',
- },
StateButton: StateButtonStub,
ToggleButton: ToggleButtonStub,
},
})
})
- describe('reload button', () => {
- it('should call listChargingStations when reload button clicked', async () => {
- const wrapper = mountView()
- const reloadButton = wrapper.findComponent({ name: 'ReloadButton' })
- await reloadButton.trigger('click')
- await flushPromises()
- expect(mockClient.listChargingStations).toHaveBeenCalled()
- })
- })
-
describe('CSTable visibility', () => {
it('should hide CSTable when no charging stations', () => {
const wrapper = mountView({ chargingStations: [] })
/**
* @file Tests for simple presentational components
- * @description Unit tests for Button, Container, ReloadButton, NotFoundView, and App.
+ * @description Unit tests for Button, Container, NotFoundView, and App.
*/
import { mount } from '@vue/test-utils'
import { describe, expect, it } from 'vitest'
import App from '@/App.vue'
import Button from '@/components/buttons/Button.vue'
-import ReloadButton from '@/components/buttons/ReloadButton.vue'
import Container from '@/components/Container.vue'
import NotFoundView from '@/views/NotFoundView.vue'
})
})
-describe('ReloadButton', () => {
- it('should render reload icon', () => {
- const wrapper = mount(ReloadButton, { props: { loading: false } })
- expect(wrapper.find('span').exists()).toBe(true)
- })
-
- it('should apply spin class when loading is true', () => {
- const wrapper = mount(ReloadButton, { props: { loading: true } })
- expect(wrapper.find('span').classes()).toContain('spin')
- })
-
- it('should not apply spin class when loading is false', () => {
- const wrapper = mount(ReloadButton, { props: { loading: false } })
- expect(wrapper.find('span').classes()).not.toContain('spin')
- })
-})
-
describe('NotFoundView', () => {
it('should render 404 message', () => {
const wrapper = mount(NotFoundView)