@real1ty-obsidian-plugins/utils 2.28.0 → 2.30.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/core/history.ts +45 -0
- package/src/core/index.ts +1 -0
- package/src/settings/settings-ui-builder.ts +0 -1
- package/dist/async/async.d.ts +0 -69
- package/dist/async/async.d.ts.map +0 -1
- package/dist/async/async.js +0 -108
- package/dist/async/async.js.map +0 -1
- package/dist/async/batch-operations.d.ts +0 -21
- package/dist/async/batch-operations.d.ts.map +0 -1
- package/dist/async/batch-operations.js +0 -60
- package/dist/async/batch-operations.js.map +0 -1
- package/dist/async/change-notifier.d.ts +0 -13
- package/dist/async/change-notifier.d.ts.map +0 -1
- package/dist/async/change-notifier.js +0 -26
- package/dist/async/change-notifier.js.map +0 -1
- package/dist/async/debounced-notifier.d.ts +0 -26
- package/dist/async/debounced-notifier.d.ts.map +0 -1
- package/dist/async/debounced-notifier.js +0 -50
- package/dist/async/debounced-notifier.js.map +0 -1
- package/dist/async/index.d.ts +0 -5
- package/dist/async/index.d.ts.map +0 -1
- package/dist/async/index.js +0 -5
- package/dist/async/index.js.map +0 -1
- package/dist/components/frontmatter-propagation-modal.d.ts +0 -17
- package/dist/components/frontmatter-propagation-modal.d.ts.map +0 -1
- package/dist/components/frontmatter-propagation-modal.js +0 -85
- package/dist/components/frontmatter-propagation-modal.js.map +0 -1
- package/dist/components/index.d.ts +0 -5
- package/dist/components/index.d.ts.map +0 -1
- package/dist/components/index.js +0 -5
- package/dist/components/index.js.map +0 -1
- package/dist/components/input-managers/base.d.ts +0 -30
- package/dist/components/input-managers/base.d.ts.map +0 -1
- package/dist/components/input-managers/base.js +0 -115
- package/dist/components/input-managers/base.js.map +0 -1
- package/dist/components/input-managers/expression.d.ts +0 -12
- package/dist/components/input-managers/expression.d.ts.map +0 -1
- package/dist/components/input-managers/expression.js +0 -56
- package/dist/components/input-managers/expression.js.map +0 -1
- package/dist/components/input-managers/index.d.ts +0 -4
- package/dist/components/input-managers/index.d.ts.map +0 -1
- package/dist/components/input-managers/index.js +0 -4
- package/dist/components/input-managers/index.js.map +0 -1
- package/dist/components/input-managers/search.d.ts +0 -6
- package/dist/components/input-managers/search.d.ts.map +0 -1
- package/dist/components/input-managers/search.js +0 -16
- package/dist/components/input-managers/search.js.map +0 -1
- package/dist/components/registered-events-component.d.ts +0 -30
- package/dist/components/registered-events-component.d.ts.map +0 -1
- package/dist/components/registered-events-component.js +0 -43
- package/dist/components/registered-events-component.js.map +0 -1
- package/dist/components/whats-new-modal.d.ts +0 -64
- package/dist/components/whats-new-modal.d.ts.map +0 -1
- package/dist/components/whats-new-modal.js +0 -139
- package/dist/components/whats-new-modal.js.map +0 -1
- package/dist/core/color-utils.d.ts +0 -17
- package/dist/core/color-utils.d.ts.map +0 -1
- package/dist/core/color-utils.js +0 -29
- package/dist/core/color-utils.js.map +0 -1
- package/dist/core/css-utils.d.ts +0 -39
- package/dist/core/css-utils.d.ts.map +0 -1
- package/dist/core/css-utils.js +0 -60
- package/dist/core/css-utils.js.map +0 -1
- package/dist/core/evaluator/base.d.ts +0 -22
- package/dist/core/evaluator/base.d.ts.map +0 -1
- package/dist/core/evaluator/base.js +0 -67
- package/dist/core/evaluator/base.js.map +0 -1
- package/dist/core/evaluator/color.d.ts +0 -19
- package/dist/core/evaluator/color.d.ts.map +0 -1
- package/dist/core/evaluator/color.js +0 -25
- package/dist/core/evaluator/color.js.map +0 -1
- package/dist/core/evaluator/excluded.d.ts +0 -32
- package/dist/core/evaluator/excluded.d.ts.map +0 -1
- package/dist/core/evaluator/excluded.js +0 -41
- package/dist/core/evaluator/excluded.js.map +0 -1
- package/dist/core/evaluator/filter.d.ts +0 -15
- package/dist/core/evaluator/filter.d.ts.map +0 -1
- package/dist/core/evaluator/filter.js +0 -27
- package/dist/core/evaluator/filter.js.map +0 -1
- package/dist/core/evaluator/included.d.ts +0 -36
- package/dist/core/evaluator/included.d.ts.map +0 -1
- package/dist/core/evaluator/included.js +0 -51
- package/dist/core/evaluator/included.js.map +0 -1
- package/dist/core/evaluator/index.d.ts +0 -6
- package/dist/core/evaluator/index.d.ts.map +0 -1
- package/dist/core/evaluator/index.js +0 -6
- package/dist/core/evaluator/index.js.map +0 -1
- package/dist/core/expression-utils.d.ts +0 -17
- package/dist/core/expression-utils.d.ts.map +0 -1
- package/dist/core/expression-utils.js +0 -40
- package/dist/core/expression-utils.js.map +0 -1
- package/dist/core/frontmatter-value.d.ts +0 -157
- package/dist/core/frontmatter-value.d.ts.map +0 -1
- package/dist/core/frontmatter-value.js +0 -417
- package/dist/core/frontmatter-value.js.map +0 -1
- package/dist/core/generate.d.ts +0 -7
- package/dist/core/generate.d.ts.map +0 -1
- package/dist/core/generate.js +0 -13
- package/dist/core/generate.js.map +0 -1
- package/dist/core/index.d.ts +0 -10
- package/dist/core/index.d.ts.map +0 -1
- package/dist/core/index.js +0 -10
- package/dist/core/index.js.map +0 -1
- package/dist/core/indexer.d.ts +0 -109
- package/dist/core/indexer.d.ts.map +0 -1
- package/dist/core/indexer.js +0 -185
- package/dist/core/indexer.js.map +0 -1
- package/dist/core/property-renderer.d.ts +0 -9
- package/dist/core/property-renderer.d.ts.map +0 -1
- package/dist/core/property-renderer.js +0 -42
- package/dist/core/property-renderer.js.map +0 -1
- package/dist/core/validation.d.ts +0 -13
- package/dist/core/validation.d.ts.map +0 -1
- package/dist/core/validation.js +0 -27
- package/dist/core/validation.js.map +0 -1
- package/dist/date/date-recurrence.d.ts +0 -30
- package/dist/date/date-recurrence.d.ts.map +0 -1
- package/dist/date/date-recurrence.js +0 -188
- package/dist/date/date-recurrence.js.map +0 -1
- package/dist/date/date.d.ts +0 -21
- package/dist/date/date.d.ts.map +0 -1
- package/dist/date/date.js +0 -105
- package/dist/date/date.js.map +0 -1
- package/dist/date/index.d.ts +0 -3
- package/dist/date/index.d.ts.map +0 -1
- package/dist/date/index.js +0 -3
- package/dist/date/index.js.map +0 -1
- package/dist/file/child-reference.d.ts +0 -9
- package/dist/file/child-reference.d.ts.map +0 -1
- package/dist/file/child-reference.js +0 -57
- package/dist/file/child-reference.js.map +0 -1
- package/dist/file/file-operations.d.ts +0 -31
- package/dist/file/file-operations.d.ts.map +0 -1
- package/dist/file/file-operations.js +0 -160
- package/dist/file/file-operations.js.map +0 -1
- package/dist/file/file-utils.d.ts +0 -33
- package/dist/file/file-utils.d.ts.map +0 -1
- package/dist/file/file-utils.js +0 -76
- package/dist/file/file-utils.js.map +0 -1
- package/dist/file/file.d.ts +0 -332
- package/dist/file/file.d.ts.map +0 -1
- package/dist/file/file.js +0 -559
- package/dist/file/file.js.map +0 -1
- package/dist/file/frontmatter-diff.d.ts +0 -38
- package/dist/file/frontmatter-diff.d.ts.map +0 -1
- package/dist/file/frontmatter-diff.js +0 -162
- package/dist/file/frontmatter-diff.js.map +0 -1
- package/dist/file/frontmatter-propagation.d.ts +0 -4
- package/dist/file/frontmatter-propagation.d.ts.map +0 -1
- package/dist/file/frontmatter-propagation.js +0 -28
- package/dist/file/frontmatter-propagation.js.map +0 -1
- package/dist/file/frontmatter-serialization.d.ts +0 -21
- package/dist/file/frontmatter-serialization.d.ts.map +0 -1
- package/dist/file/frontmatter-serialization.js +0 -57
- package/dist/file/frontmatter-serialization.js.map +0 -1
- package/dist/file/frontmatter.d.ts +0 -15
- package/dist/file/frontmatter.d.ts.map +0 -1
- package/dist/file/frontmatter.js +0 -68
- package/dist/file/frontmatter.js.map +0 -1
- package/dist/file/index.d.ts +0 -13
- package/dist/file/index.d.ts.map +0 -1
- package/dist/file/index.js +0 -13
- package/dist/file/index.js.map +0 -1
- package/dist/file/link-parser.d.ts +0 -63
- package/dist/file/link-parser.d.ts.map +0 -1
- package/dist/file/link-parser.js +0 -137
- package/dist/file/link-parser.js.map +0 -1
- package/dist/file/property-utils.d.ts +0 -55
- package/dist/file/property-utils.d.ts.map +0 -1
- package/dist/file/property-utils.js +0 -90
- package/dist/file/property-utils.js.map +0 -1
- package/dist/file/templater-service.d.ts +0 -16
- package/dist/file/templater-service.d.ts.map +0 -1
- package/dist/file/templater-service.js +0 -37
- package/dist/file/templater-service.js.map +0 -1
- package/dist/file/templater.d.ts +0 -28
- package/dist/file/templater.d.ts.map +0 -1
- package/dist/file/templater.js +0 -126
- package/dist/file/templater.js.map +0 -1
- package/dist/index.d.ts +0 -9
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js +0 -17
- package/dist/index.js.map +0 -1
- package/dist/inputs/index.d.ts +0 -2
- package/dist/inputs/index.d.ts.map +0 -1
- package/dist/inputs/index.js +0 -2
- package/dist/inputs/index.js.map +0 -1
- package/dist/inputs/input-filter-manager.d.ts +0 -72
- package/dist/inputs/input-filter-manager.d.ts.map +0 -1
- package/dist/inputs/input-filter-manager.js +0 -140
- package/dist/inputs/input-filter-manager.js.map +0 -1
- package/dist/settings/index.d.ts +0 -3
- package/dist/settings/index.d.ts.map +0 -1
- package/dist/settings/index.js +0 -3
- package/dist/settings/index.js.map +0 -1
- package/dist/settings/settings-store.d.ts +0 -20
- package/dist/settings/settings-store.d.ts.map +0 -1
- package/dist/settings/settings-store.js +0 -82
- package/dist/settings/settings-store.js.map +0 -1
- package/dist/settings/settings-ui-builder.d.ts +0 -74
- package/dist/settings/settings-ui-builder.d.ts.map +0 -1
- package/dist/settings/settings-ui-builder.js +0 -437
- package/dist/settings/settings-ui-builder.js.map +0 -1
- package/dist/string/changelog-parser.d.ts +0 -17
- package/dist/string/changelog-parser.d.ts.map +0 -1
- package/dist/string/changelog-parser.js +0 -77
- package/dist/string/changelog-parser.js.map +0 -1
- package/dist/string/filename-utils.d.ts +0 -46
- package/dist/string/filename-utils.d.ts.map +0 -1
- package/dist/string/filename-utils.js +0 -65
- package/dist/string/filename-utils.js.map +0 -1
- package/dist/string/index.d.ts +0 -4
- package/dist/string/index.d.ts.map +0 -1
- package/dist/string/index.js +0 -4
- package/dist/string/index.js.map +0 -1
- package/dist/string/string.d.ts +0 -5
- package/dist/string/string.d.ts.map +0 -1
- package/dist/string/string.js +0 -25
- package/dist/string/string.js.map +0 -1
- package/dist/testing/index.d.ts +0 -5
- package/dist/testing/index.d.ts.map +0 -1
- package/dist/testing/index.js +0 -6
- package/dist/testing/index.js.map +0 -1
- package/dist/testing/mocks/obsidian.d.ts +0 -150
- package/dist/testing/mocks/obsidian.d.ts.map +0 -1
- package/dist/testing/mocks/obsidian.js +0 -226
- package/dist/testing/mocks/obsidian.js.map +0 -1
- package/dist/testing/mocks/utils.d.ts +0 -14
- package/dist/testing/mocks/utils.d.ts.map +0 -1
- package/dist/testing/mocks/utils.js +0 -85
- package/dist/testing/mocks/utils.js.map +0 -1
- package/dist/testing/setup.d.ts +0 -2
- package/dist/testing/setup.d.ts.map +0 -1
- package/dist/testing/setup.js +0 -18
- package/dist/testing/setup.js.map +0 -1
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/testing/mocks/utils.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,kBAAkB;;;;CAI9B,CAAC;AAGF,eAAO,MAAM,cAAc;;CAE1B,CAAC;AAGF,wBAAgB,+BAA+B,SA+C9C;AAGD,wBAAgB,aAAa,SAO5B;AAGD,wBAAgB,uBAAuB,CACtC,QAAQ,EAAE,MAAM,OAAO,kBAAkB,GAAG,MAAM,OAAO,cAAc,EACvE,cAAc,EAAE,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,GAAG,QAOvC;AAGD,wBAAgB,oBAAoB,CACnC,QAAQ,EAAE,MAAM,OAAO,kBAAkB,GAAG,MAAM,OAAO,cAAc,EACvE,KAAK,EAAE,GAAG,QAOV;AAGD,wBAAgB,eAAe,CAC9B,QAAQ,EAAE,MAAM,OAAO,kBAAkB,GAAG,MAAM,OAAO,cAAc,EACvE,aAAa,EAAE,GAAG,EAAE,EAAE,QAWtB"}
|
|
@@ -1,85 +0,0 @@
|
|
|
1
|
-
import { expect, vi } from "vitest";
|
|
2
|
-
// File operations mocks
|
|
3
|
-
export const mockFileOperations = {
|
|
4
|
-
arraysEqual: vi.fn(),
|
|
5
|
-
normalizeArray: vi.fn(),
|
|
6
|
-
createFileLink: vi.fn(),
|
|
7
|
-
};
|
|
8
|
-
// Link parser mocks
|
|
9
|
-
export const mockLinkParser = {
|
|
10
|
-
extractFilePathFromLink: vi.fn(),
|
|
11
|
-
};
|
|
12
|
-
// Default mock implementations that match the actual behavior
|
|
13
|
-
export function setupDefaultMockImplementations() {
|
|
14
|
-
// Set up file operations mocks
|
|
15
|
-
mockFileOperations.normalizeArray.mockImplementation((arr) => Array.isArray(arr) ? arr : arr ? [arr] : []);
|
|
16
|
-
mockFileOperations.arraysEqual.mockImplementation((a, b) => JSON.stringify(a) === JSON.stringify(b));
|
|
17
|
-
mockFileOperations.createFileLink.mockImplementation((file) => {
|
|
18
|
-
var _a, _b, _c;
|
|
19
|
-
if (!file)
|
|
20
|
-
return "[[Unknown File]]";
|
|
21
|
-
const basename = file.basename ||
|
|
22
|
-
((_b = (_a = file.path) === null || _a === void 0 ? void 0 : _a.split("/").pop()) === null || _b === void 0 ? void 0 : _b.replace(/\.[^/.]+$/, "")) ||
|
|
23
|
-
"";
|
|
24
|
-
const parentPath = (_c = file.parent) === null || _c === void 0 ? void 0 : _c.path;
|
|
25
|
-
if (!parentPath || parentPath === "/" || parentPath === "") {
|
|
26
|
-
return `[[${basename}]]`;
|
|
27
|
-
}
|
|
28
|
-
return `[[${parentPath}/${basename}|${basename}]]`;
|
|
29
|
-
});
|
|
30
|
-
// Set up link parser mocks
|
|
31
|
-
mockLinkParser.extractFilePathFromLink.mockImplementation((link) => {
|
|
32
|
-
if (!link || typeof link !== "string")
|
|
33
|
-
return null;
|
|
34
|
-
// Handle text that contains a link
|
|
35
|
-
const linkMatch = link.match(/\[\[([^\]]+)\]\]/);
|
|
36
|
-
if (linkMatch) {
|
|
37
|
-
const content = linkMatch[1];
|
|
38
|
-
// Remove display name if present
|
|
39
|
-
const filePart = content.split("|")[0].trim();
|
|
40
|
-
if (!filePart)
|
|
41
|
-
return null;
|
|
42
|
-
// Add .md extension if not present
|
|
43
|
-
return filePart.endsWith(".md") ? filePart : `${filePart}.md`;
|
|
44
|
-
}
|
|
45
|
-
return null;
|
|
46
|
-
});
|
|
47
|
-
}
|
|
48
|
-
// Reset all mocks
|
|
49
|
-
export function resetAllMocks() {
|
|
50
|
-
Object.values(mockFileOperations).forEach((mock) => {
|
|
51
|
-
mock.mockReset();
|
|
52
|
-
});
|
|
53
|
-
Object.values(mockLinkParser).forEach((mock) => {
|
|
54
|
-
mock.mockReset();
|
|
55
|
-
});
|
|
56
|
-
}
|
|
57
|
-
// Helper to setup mocks with specific implementations
|
|
58
|
-
export function setupMockImplementation(mockName, implementation) {
|
|
59
|
-
if (mockName in mockFileOperations) {
|
|
60
|
-
mockFileOperations[mockName].mockImplementation(implementation);
|
|
61
|
-
}
|
|
62
|
-
else if (mockName in mockLinkParser) {
|
|
63
|
-
mockLinkParser[mockName].mockImplementation(implementation);
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
// Helper to setup mock return values
|
|
67
|
-
export function setupMockReturnValue(mockName, value) {
|
|
68
|
-
if (mockName in mockFileOperations) {
|
|
69
|
-
mockFileOperations[mockName].mockReturnValue(value);
|
|
70
|
-
}
|
|
71
|
-
else if (mockName in mockLinkParser) {
|
|
72
|
-
mockLinkParser[mockName].mockReturnValue(value);
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
// Helper to verify mock calls
|
|
76
|
-
export function verifyMockCalls(mockName, expectedCalls) {
|
|
77
|
-
const mock = mockName in mockFileOperations
|
|
78
|
-
? mockFileOperations[mockName]
|
|
79
|
-
: mockLinkParser[mockName];
|
|
80
|
-
expect(mock).toHaveBeenCalledTimes(expectedCalls.length);
|
|
81
|
-
expectedCalls.forEach((args, index) => {
|
|
82
|
-
expect(mock).toHaveBeenNthCalledWith(index + 1, ...args);
|
|
83
|
-
});
|
|
84
|
-
}
|
|
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KAAK,GAAG,CAAC,EAAE,GAAG,IAAI,CAAC,CAAC;IAC1D,CAAC,CAAC,CAAC;AACJ,CAAC","sourcesContent":["import { expect, vi } from \"vitest\";\n\n// File operations mocks\nexport const mockFileOperations = {\n\tarraysEqual: vi.fn(),\n\tnormalizeArray: vi.fn(),\n\tcreateFileLink: vi.fn(),\n};\n\n// Link parser mocks\nexport const mockLinkParser = {\n\textractFilePathFromLink: vi.fn(),\n};\n\n// Default mock implementations that match the actual behavior\nexport function setupDefaultMockImplementations() {\n\t// Set up file operations mocks\n\tmockFileOperations.normalizeArray.mockImplementation((arr) =>\n\t\tArray.isArray(arr) ? arr : arr ? [arr] : []\n\t);\n\n\tmockFileOperations.arraysEqual.mockImplementation(\n\t\t(a, b) => JSON.stringify(a) === JSON.stringify(b)\n\t);\n\n\tmockFileOperations.createFileLink.mockImplementation((file) => {\n\t\tif (!file) return \"[[Unknown File]]\";\n\n\t\tconst basename =\n\t\t\tfile.basename ||\n\t\t\tfile.path\n\t\t\t\t?.split(\"/\")\n\t\t\t\t.pop()\n\t\t\t\t?.replace(/\\.[^/.]+$/, \"\") ||\n\t\t\t\"\";\n\t\tconst parentPath = file.parent?.path;\n\n\t\tif (!parentPath || parentPath === \"/\" || parentPath === \"\") {\n\t\t\treturn `[[${basename}]]`;\n\t\t}\n\n\t\treturn `[[${parentPath}/${basename}|${basename}]]`;\n\t});\n\n\t// Set up link parser mocks\n\tmockLinkParser.extractFilePathFromLink.mockImplementation((link) => {\n\t\tif (!link || typeof link !== \"string\") return null;\n\n\t\t// Handle text that contains a link\n\t\tconst linkMatch = link.match(/\\[\\[([^\\]]+)\\]\\]/);\n\t\tif (linkMatch) {\n\t\t\tconst content = linkMatch[1];\n\t\t\t// Remove display name if present\n\t\t\tconst filePart = content.split(\"|\")[0].trim();\n\t\t\tif (!filePart) return null;\n\n\t\t\t// Add .md extension if not present\n\t\t\treturn filePart.endsWith(\".md\") ? filePart : `${filePart}.md`;\n\t\t}\n\n\t\treturn null;\n\t});\n}\n\n// Reset all mocks\nexport function resetAllMocks() {\n\tObject.values(mockFileOperations).forEach((mock) => {\n\t\tmock.mockReset();\n\t});\n\tObject.values(mockLinkParser).forEach((mock) => {\n\t\tmock.mockReset();\n\t});\n}\n\n// Helper to setup mocks with specific implementations\nexport function setupMockImplementation(\n\tmockName: keyof typeof mockFileOperations | keyof typeof mockLinkParser,\n\timplementation: (...args: any[]) => any\n) {\n\tif (mockName in mockFileOperations) {\n\t\t(mockFileOperations as any)[mockName].mockImplementation(implementation);\n\t} else if (mockName in mockLinkParser) {\n\t\t(mockLinkParser as any)[mockName].mockImplementation(implementation);\n\t}\n}\n\n// Helper to setup mock return values\nexport function setupMockReturnValue(\n\tmockName: keyof typeof mockFileOperations | keyof typeof mockLinkParser,\n\tvalue: any\n) {\n\tif (mockName in mockFileOperations) {\n\t\t(mockFileOperations as any)[mockName].mockReturnValue(value);\n\t} else if (mockName in mockLinkParser) {\n\t\t(mockLinkParser as any)[mockName].mockReturnValue(value);\n\t}\n}\n\n// Helper to verify mock calls\nexport function verifyMockCalls(\n\tmockName: keyof typeof mockFileOperations | keyof typeof mockLinkParser,\n\texpectedCalls: any[][]\n) {\n\tconst mock =\n\t\tmockName in mockFileOperations\n\t\t\t? (mockFileOperations as any)[mockName]\n\t\t\t: (mockLinkParser as any)[mockName];\n\n\texpect(mock).toHaveBeenCalledTimes(expectedCalls.length);\n\texpectedCalls.forEach((args, index) => {\n\t\texpect(mock).toHaveBeenNthCalledWith(index + 1, ...args);\n\t});\n}\n"]}
|
package/dist/testing/setup.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"setup.d.ts","sourceRoot":"","sources":["../../src/testing/setup.ts"],"names":[],"mappings":"AAIA,wBAAgB,oBAAoB,eAcnC"}
|
package/dist/testing/setup.js
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { vi } from "vitest";
|
|
2
|
-
import { mockFileOperations, mockLinkParser } from "./mocks/utils";
|
|
3
|
-
// Global test setup that can be imported once per test file
|
|
4
|
-
export function setupTestEnvironment() {
|
|
5
|
-
// Mock the utils modules
|
|
6
|
-
vi.mock("@obsidian-plugins/utils/file-operations", () => mockFileOperations);
|
|
7
|
-
vi.mock("@obsidian-plugins/utils/link-parser", () => mockLinkParser);
|
|
8
|
-
// Mock any plugin-specific components
|
|
9
|
-
vi.mock("../src/components/settings-tab", () => ({
|
|
10
|
-
TreePropertiesManagerSettingTab: class MockSettingTab {
|
|
11
|
-
},
|
|
12
|
-
}));
|
|
13
|
-
// Return cleanup function
|
|
14
|
-
return () => {
|
|
15
|
-
vi.clearAllMocks();
|
|
16
|
-
};
|
|
17
|
-
}
|
|
18
|
-
//# sourceMappingURL=setup.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"setup.js","sourceRoot":"","sources":["../../src/testing/setup.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAC;AAC5B,OAAO,EAAE,kBAAkB,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAEnE,4DAA4D;AAC5D,MAAM,UAAU,oBAAoB;IACnC,yBAAyB;IACzB,EAAE,CAAC,IAAI,CAAC,yCAAyC,EAAE,GAAG,EAAE,CAAC,kBAAkB,CAAC,CAAC;IAC7E,EAAE,CAAC,IAAI,CAAC,qCAAqC,EAAE,GAAG,EAAE,CAAC,cAAc,CAAC,CAAC;IAErE,sCAAsC;IACtC,EAAE,CAAC,IAAI,CAAC,gCAAgC,EAAE,GAAG,EAAE,CAAC,CAAC;QAChD,+BAA+B,EAAE,MAAM,cAAc;SAAG;KACxD,CAAC,CAAC,CAAC;IAEJ,0BAA0B;IAC1B,OAAO,GAAG,EAAE;QACX,EAAE,CAAC,aAAa,EAAE,CAAC;IACpB,CAAC,CAAC;AACH,CAAC","sourcesContent":["import { vi } from \"vitest\";\nimport { mockFileOperations, mockLinkParser } from \"./mocks/utils\";\n\n// Global test setup that can be imported once per test file\nexport function setupTestEnvironment() {\n\t// Mock the utils modules\n\tvi.mock(\"@obsidian-plugins/utils/file-operations\", () => mockFileOperations);\n\tvi.mock(\"@obsidian-plugins/utils/link-parser\", () => mockLinkParser);\n\n\t// Mock any plugin-specific components\n\tvi.mock(\"../src/components/settings-tab\", () => ({\n\t\tTreePropertiesManagerSettingTab: class MockSettingTab {},\n\t}));\n\n\t// Return cleanup function\n\treturn () => {\n\t\tvi.clearAllMocks();\n\t};\n}\n"]}
|