Refactor repo-projects.ts (#32892)
- Remove jQuery - Add types to all functions - Tested all modified functionality --------- Co-authored-by: Giteabot <teabot@gitea.io> Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
This commit is contained in:
parent
dc8f59baa5
commit
141d782c1a
8 changed files with 148 additions and 235 deletions
|
@ -2,7 +2,8 @@ import {beforeEach, describe, expect, test, vi} from 'vitest';
|
|||
import {initRepoSettingsBranchesDrag} from './repo-settings-branches.ts';
|
||||
import {POST} from '../modules/fetch.ts';
|
||||
import {createSortable} from '../modules/sortable.ts';
|
||||
import type {SortableEvent} from 'sortablejs';
|
||||
import type {SortableEvent, SortableOptions} from 'sortablejs';
|
||||
import type Sortable from 'sortablejs';
|
||||
|
||||
vi.mock('../modules/fetch.ts', () => ({
|
||||
POST: vi.fn(),
|
||||
|
@ -55,9 +56,10 @@ describe('Repository Branch Settings', () => {
|
|||
vi.mocked(POST).mockResolvedValue({ok: true} as Response);
|
||||
|
||||
// Mock createSortable to capture and execute the onEnd callback
|
||||
vi.mocked(createSortable).mockImplementation(async (_el: Element, options) => {
|
||||
vi.mocked(createSortable).mockImplementation(async (_el: Element, options: SortableOptions) => {
|
||||
options.onEnd(new Event('SortableEvent') as SortableEvent);
|
||||
return {destroy: vi.fn()};
|
||||
// @ts-expect-error: mock is incomplete
|
||||
return {destroy: vi.fn()} as Sortable;
|
||||
});
|
||||
|
||||
initRepoSettingsBranchesDrag();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue