MCPcopy Create free account
hub / github.com/massCodeIO/massCode / setup

Function setup

src/renderer/composables/__tests__/useSnippetsSearch.test.ts:17–104  ·  view source on GitHub ↗
(options: SetupOptions = {})

Source from the content-addressed store, hash-verified

15}
16
17async function setup(options: SetupOptions = {}) {
18 vi.resetModules()
19
20 const state = reactive<{
21 folderId?: number
22 libraryFilter?: string
23 snippetContentIndex?: number
24 snippetId?: number
25 tagId?: number
26 }>({
27 folderId: options.folderId,
28 libraryFilter: options.libraryFilter,
29 snippetContentIndex: 0,
30 tagId: options.tagId,
31 })
32
33 const getSnippets = vi.fn(async () => ({
34 data: [{ contents: [], id: 1, name: 'Search result', tags: [] }],
35 }))
36
37 vi.doMock('@/composables/useDonations', () => ({
38 useDonations: () => ({
39 incrementCopy: vi.fn(),
40 incrementCreated: vi.fn(),
41 }),
42 }))
43
44 vi.doMock('@/composables/useStorageMutation', () => ({
45 markPersistedStorageMutation: vi.fn(),
46 }))
47
48 vi.doMock('@/electron', () => ({
49 i18n: {
50 t: (key: string) => key,
51 },
52 }))
53
54 vi.doMock('@/utils', () => ({
55 getContiguousSelection: vi.fn(() => []),
56 }))
57
58 vi.doMock('~/renderer/services/api', () => ({
59 api: {
60 snippets: {
61 deleteSnippetsById: vi.fn(),
62 deleteSnippetsByIdContentsByContentId: vi.fn(),
63 deleteSnippetsByIdTagsByTagId: vi.fn(),
64 deleteSnippetsTrash: vi.fn(),
65 getSnippets,
66 patchSnippetsById: vi.fn(),
67 patchSnippetsByIdContentsByContentId: vi.fn(),
68 postSnippets: vi.fn(),
69 postSnippetsByIdContents: vi.fn(),
70 postSnippetsByIdTagsByTagId: vi.fn(),
71 },
72 },
73 }))
74

Callers 1

Calls 1

useSnippetsFunction · 0.85

Tested by

no test coverage detected