Skip to content
This repository was archived by the owner on Jul 28, 2025. It is now read-only.

Commit 89318b1

Browse files
committed
the test asre still imposibble to use without ahuge effort with the obsidian api
1 parent c82a286 commit 89318b1

File tree

3 files changed

+17
-28
lines changed

3 files changed

+17
-28
lines changed

src/__tests__/IO/settings.test.ts

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { YamlHandlerResponse } from "cdm/MashallModel";
2+
import { mockReset, mockDeep, DeepMockProxy } from "jest-mock-extended";
23
import { parseYamlMock } from "mock/mockObsidianUtils";
34
import DatabaseStringToYamlParser from "parsers/DatabaseStringToYamlParser";
45

@@ -8,12 +9,20 @@ jest.mock("obsidian",
89
return {
910
parseYaml: jest.fn(() => {
1011
return parseYamlMock(1, 1);
11-
}
12-
),
12+
}),
1313
};
1414
}
1515
);
1616
describe("Settings", () => {
17+
// @ts-ignore
18+
const mockGlobalApp: DeepMockProxy<App> = mockDeep<App>();
19+
/**
20+
* Run this before each test.
21+
*/
22+
beforeAll(() => {
23+
mockReset(mockGlobalApp);
24+
global.app = mockGlobalApp;
25+
});
1726
/** Parse string YAML */
1827
test("Parse Database string to Yaml", () => {
1928
const yamlResponse: YamlHandlerResponse = DatabaseStringToYamlParser("test");

src/mock/mockObsidianUtils.ts

Lines changed: 4 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,13 @@
1-
import { parseYaml } from "obsidian";
1+
import { generateYamlColumns } from "mock/mockTableUtils";
2+
import { DEFAULT_SETTINGS } from "helpers/Constants";
23

34
/** Mock parseYaml returning YamlHandlerResponse object */
45
export const parseYamlMock = (numOfColumns: number, numberOfFilters: number) => {
56
return {
67
name: "Test",
78
description: "Test",
8-
columns: {
9-
"test": {
10-
input: "text",
11-
accessor: "test",
12-
label: "test",
13-
key: "test",
14-
position: 1,
15-
isMetadata: true,
16-
skipPersist: false,
17-
csvCandidate: true,
18-
isInline: false
19-
}
20-
},
21-
config: {
22-
enable_show_state: false,
23-
group_folder_column: "test"
24-
},
9+
columns: generateYamlColumns(numOfColumns),
10+
config: DEFAULT_SETTINGS.local_settings,
2511
filters: [
2612
{
2713
field: "test",

src/mock/mockTableUtils.tsx

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import faker from "@faker-js/faker";
33
import React, { useRef, useLayoutEffect } from "react";
44
import { randomColor } from "helpers/Colors";
5-
import { DataTypes } from "helpers/Constants";
5+
import { DataTypes, DEFAULT_COLUMN_CONFIG } from "helpers/Constants";
66
import { TableDataType, TableColumn, RowDataType } from "cdm/FolderModel";
77
import { DatabaseColumn } from "cdm/DatabaseModel";
88
import { obtainColumnsFromFolder } from "components/Columns";
@@ -36,7 +36,6 @@ export async function makeData(count: number): Promise<TableDataType> {
3636
skipReset: false,
3737
view: null,
3838
stateManager: null,
39-
cellSize: "normal",
4039
};
4140
}
4241

@@ -60,12 +59,7 @@ export const generateYamlColumns = (
6059
isMetadata: false,
6160
skipPersist: true,
6261
csvCandidate: false,
63-
config: {
64-
enable_media_view: true,
65-
media_width: 100,
66-
media_height: 100,
67-
isInline: false,
68-
},
62+
config: DEFAULT_COLUMN_CONFIG,
6963
};
7064
}
7165
return yamlColumns;

0 commit comments

Comments
 (0)