chore: fix tests & lints

This commit is contained in:
Yaros
2025-12-12 16:00:59 +01:00
parent 5bc80f427a
commit 1101c0b623
2 changed files with 34 additions and 13 deletions

View File

@@ -103,6 +103,8 @@ describe(MapService.name, () => {
name: 'Home', name: 'Home',
latitude: 12.34, latitude: 12.34,
longitude: 56.78, longitude: 56.78,
createdAt: new Date(),
updatedAt: new Date(),
}; };
mocks.map.getFavoriteLocations.mockResolvedValue([favoriteLocation]); mocks.map.getFavoriteLocations.mockResolvedValue([favoriteLocation]);
@@ -118,7 +120,16 @@ describe(MapService.name, () => {
describe('createFavoriteLocation', () => { describe('createFavoriteLocation', () => {
it('should create a new favorite location', async () => { it('should create a new favorite location', async () => {
const dto: CreateFavoriteLocationDto = { name: 'Work', latitude: 1, longitude: 2 }; const dto: CreateFavoriteLocationDto = { name: 'Work', latitude: 1, longitude: 2 };
const created = { id: 'loc2', userId: authStub.user1.user.id, ...dto };
const created = {
id: 'loc2',
userId: authStub.user1.user.id,
name: 'Work',
latitude: 1,
longitude: 2,
createdAt: new Date(),
updatedAt: new Date(),
};
mocks.map.createFavoriteLocation.mockResolvedValue(created); mocks.map.createFavoriteLocation.mockResolvedValue(created);
@@ -137,7 +148,16 @@ describe(MapService.name, () => {
describe('updateFavoriteLocation', () => { describe('updateFavoriteLocation', () => {
it('should update an existing favorite location', async () => { it('should update an existing favorite location', async () => {
const dto: UpdateFavoriteLocationDto = { name: 'Gym' }; const dto: UpdateFavoriteLocationDto = { name: 'Gym' };
const updated = { id: 'loc3', userId: authStub.user1.user.id, name: 'Gym', latitude: null, longitude: null };
const updated = {
id: 'loc3',
userId: authStub.user1.user.id,
name: 'Gym',
latitude: null,
longitude: null,
createdAt: new Date(),
updatedAt: new Date(),
};
mocks.map.updateFavoriteLocation.mockResolvedValue(updated); mocks.map.updateFavoriteLocation.mockResolvedValue(updated);
@@ -154,7 +174,7 @@ describe(MapService.name, () => {
describe('deleteFavoriteLocation', () => { describe('deleteFavoriteLocation', () => {
it('should call repository to delete a location by id', async () => { it('should call repository to delete a location by id', async () => {
mocks.map.deleteFavoriteLocation.mockResolvedValue(undefined); mocks.map.deleteFavoriteLocation.mockResolvedValue();
await sut.deleteFavoriteLocation('loc4'); await sut.deleteFavoriteLocation('loc4');

View File

@@ -61,13 +61,13 @@
const loadFavoriteLocations = async () => { const loadFavoriteLocations = async () => {
try { try {
favoriteLocations = await getFavoriteLocations(); favoriteLocations = await getFavoriteLocations();
} catch (err) { } catch (error) {
handleError(err, 'Failed to load favorite locations'); handleError(error, 'Failed to load favorite locations');
} }
}; };
onMount(() => { onMount(async () => {
loadFavoriteLocations(); await loadFavoriteLocations();
}); });
$effect(() => { $effect(() => {
@@ -110,8 +110,8 @@
favoriteLocations = [...favoriteLocations, newLocation]; favoriteLocations = [...favoriteLocations, newLocation];
favoriteLocations = favoriteLocations.sort((a, b) => a.name.localeCompare(b.name)); favoriteLocations = favoriteLocations.sort((a, b) => a.name.localeCompare(b.name));
newFavoriteName = ''; newFavoriteName = '';
} catch (err) { } catch (error) {
handleError(err, 'Failed to save favorite location'); handleError(error, 'Failed to save favorite location');
} finally { } finally {
savingFavorite = false; savingFavorite = false;
} }
@@ -121,8 +121,8 @@
try { try {
await deleteFavoriteLocation({ id: locationId }); await deleteFavoriteLocation({ id: locationId });
favoriteLocations = favoriteLocations.filter((loc) => loc.id !== locationId); favoriteLocations = favoriteLocations.filter((loc) => loc.id !== locationId);
} catch (err) { } catch (error) {
handleError(err, 'Failed to delete favorite location'); handleError(error, 'Failed to delete favorite location');
} }
}; };
@@ -291,6 +291,7 @@
{#each favoriteLocations as location (location.id)} {#each favoriteLocations as location (location.id)}
<li> <li>
<button <button
type="button"
class="w-full" class="w-full"
onclick={() => handleUseSuggested(location.latitude!, location.longitude!, 14)} onclick={() => handleUseSuggested(location.latitude!, location.longitude!, 14)}
> >
@@ -305,9 +306,9 @@
size="medium" size="medium"
color="danger" color="danger"
aria-label={$t('delete')} aria-label={$t('delete')}
onclick={(e: Event) => { onclick={async (e: Event) => {
e.stopPropagation(); e.stopPropagation();
handleDeleteFavorite(location.id); await handleDeleteFavorite(location.id);
}} }}
/> />
</div> </div>