mirror of
https://github.com/immich-app/immich.git
synced 2025-12-03 23:29:46 +09:00
refactor(web): asset interaction (#14662)
* refactor(web): asset interaction * feedback
This commit is contained in:
40
web/src/lib/stores/asset-interaction.svelte.spec.ts
Normal file
40
web/src/lib/stores/asset-interaction.svelte.spec.ts
Normal file
@@ -0,0 +1,40 @@
|
||||
import { AssetInteraction } from '$lib/stores/asset-interaction.svelte';
|
||||
import { resetSavedUser, user } from '$lib/stores/user.store';
|
||||
import { assetFactory } from '@test-data/factories/asset-factory';
|
||||
import { userAdminFactory } from '@test-data/factories/user-factory';
|
||||
|
||||
describe('AssetInteraction', () => {
|
||||
let assetInteraction: AssetInteraction;
|
||||
|
||||
beforeEach(() => {
|
||||
assetInteraction = new AssetInteraction();
|
||||
});
|
||||
|
||||
it('calculates derived values from selection', () => {
|
||||
assetInteraction.selectAsset(assetFactory.build({ isFavorite: true, isArchived: true, isTrashed: true }));
|
||||
assetInteraction.selectAsset(assetFactory.build({ isFavorite: true, isArchived: false, isTrashed: false }));
|
||||
|
||||
expect(assetInteraction.selectionActive).toBe(true);
|
||||
expect(assetInteraction.isAllTrashed).toBe(false);
|
||||
expect(assetInteraction.isAllArchived).toBe(false);
|
||||
expect(assetInteraction.isAllFavorite).toBe(true);
|
||||
});
|
||||
|
||||
it('updates isAllUserOwned when the active user changes', () => {
|
||||
const [user1, user2] = userAdminFactory.buildList(2);
|
||||
assetInteraction.selectAsset(assetFactory.build({ ownerId: user1.id }));
|
||||
|
||||
const cleanup = $effect.root(() => {
|
||||
expect(assetInteraction.isAllUserOwned).toBe(false);
|
||||
|
||||
user.set(user1);
|
||||
expect(assetInteraction.isAllUserOwned).toBe(true);
|
||||
|
||||
user.set(user2);
|
||||
expect(assetInteraction.isAllUserOwned).toBe(false);
|
||||
});
|
||||
|
||||
cleanup();
|
||||
resetSavedUser();
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user