MCPcopy Index your code
hub / github.com/simstudioai/sim / createMockTx

Function createMockTx

apps/sim/lib/workflows/persistence/duplicate.test.ts:29–69  ·  view source on GitHub ↗
(
  selectResults: unknown[],
  onWorkflowInsert?: (values: Record<string, unknown>) => void,
  onInsert?: (values: unknown) => void
)

Source from the content-addressed store, hash-verified

27import { duplicateWorkflow } from './duplicate'
28
29function createMockTx(
30 selectResults: unknown[],
31 onWorkflowInsert?: (values: Record<string, unknown>) => void,
32 onInsert?: (values: unknown) => void
33) {
34 let selectCallCount = 0
35
36 const select = vi.fn().mockImplementation(() => ({
37 from: vi.fn().mockReturnValue({
38 where: vi.fn().mockImplementation(() => {
39 const result = selectResults[selectCallCount++] ?? []
40 if (selectCallCount === 1) {
41 return {
42 limit: vi.fn().mockResolvedValue(result),
43 }
44 }
45 return Promise.resolve(result)
46 }),
47 }),
48 }))
49
50 const insert = vi.fn().mockReturnValue({
51 values: vi.fn().mockImplementation((values: Record<string, unknown>) => {
52 onWorkflowInsert?.(values)
53 onInsert?.(values)
54 return Promise.resolve(undefined)
55 }),
56 })
57
58 const update = vi.fn().mockReturnValue({
59 set: vi.fn().mockReturnValue({
60 where: vi.fn().mockResolvedValue(undefined),
61 }),
62 })
63
64 return {
65 select,
66 insert,
67 update,
68 }
69}
70
71describe('duplicateWorkflow ordering', () => {
72 beforeEach(() => {

Callers 1

duplicate.test.tsFile · 0.85

Calls 1

resolveMethod · 0.65

Tested by

no test coverage detected