feat: Implement basic general folder support (#2051)

- Related: #1748
This commit is contained in:
Dermot Duffy
2025-05-21 19:59:21 -07:00
committed by GitHub
parent 2eb0d9e35e
commit c6a4c8aea2
350 changed files with 12837 additions and 4509 deletions
@@ -1,9 +1,17 @@
import { expect, it } from 'vitest';
import { expect, it, vi } from 'vitest';
import { DownloadAction } from '../../../../src/card-controller/actions/actions/download';
import { createCardAPI } from '../../../test-utils';
import { QueryResults } from '../../../../src/view/query-results';
import { createCardAPI, createView, TestViewMedia } from '../../../test-utils';
it('should handle download action', async () => {
it('should handle download action with selected media', async () => {
const api = createCardAPI();
const selectedMedia = new TestViewMedia();
vi.mocked(api.getViewManager().getView).mockReturnValue(
createView({
queryResults: new QueryResults({ results: [selectedMedia], selectedIndex: 0 }),
}),
);
const action = new DownloadAction(
{},
{
@@ -14,5 +22,22 @@ it('should handle download action', async () => {
await action.execute(api);
expect(api.getDownloadManager().downloadViewerMedia).toBeCalled();
expect(api.getViewItemManager().download).toBeCalledWith(selectedMedia);
});
it('should handle download action without selected media', async () => {
const api = createCardAPI();
vi.mocked(api.getViewManager().getView).mockReturnValue(createView());
const action = new DownloadAction(
{},
{
action: 'fire-dom-event',
advanced_camera_card_action: 'download',
},
);
await action.execute(api);
expect(api.getViewItemManager().download).not.toBeCalled();
});