MCPcopy Index your code
hub / github.com/callumalpass/tasknotes / createHarness

Function createHarness

tests/unit/modals/taskModalActionMenus.test.ts:69–119  ·  view source on GitHub ↗
(overrides: Partial<TaskModalActionMenuState> = {})

Source from the content-addressed store, hash-verified

67} from "../../../src/modals/taskModalActionMenus";
68
69function createHarness(overrides: Partial<TaskModalActionMenuState> = {}): {
70 context: TaskModalActionMenuContext;
71 getState: () => TaskModalActionMenuState;
72 onChange: jest.Mock;
73 plugin: any;
74} {
75 let state: TaskModalActionMenuState = {
76 title: "Menu task",
77 status: "open",
78 priority: "normal",
79 dueDate: "",
80 scheduledDate: "",
81 recurrenceRule: "",
82 recurrenceAnchor: "scheduled",
83 reminders: [],
84 ...overrides,
85 };
86 const onChange = jest.fn();
87 const plugin = { settings: {} };
88 const context: TaskModalActionMenuContext = {
89 app: {} as TaskModalActionMenuContext["app"],
90 plugin,
91 translate: (key) => `translated:${key}`,
92 getState: () => state,
93 setDate: (type, value) => {
94 state = {
95 ...state,
96 [type === "due" ? "dueDate" : "scheduledDate"]: value,
97 };
98 },
99 setStatus: (value) => {
100 state = { ...state, status: value };
101 },
102 setPriority: (value) => {
103 state = { ...state, priority: value };
104 },
105 setRecurrence: (value, anchor) => {
106 state = {
107 ...state,
108 recurrenceRule: value,
109 recurrenceAnchor: anchor ?? state.recurrenceAnchor,
110 };
111 },
112 setReminders: (reminders) => {
113 state = { ...state, reminders };
114 },
115 onChange,
116 };
117
118 return { context, getState: () => state, onChange, plugin };
119}
120
121describe("taskModalActionMenus", () => {
122 beforeEach(() => {

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected