This repository was archived by the owner on Jul 28, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 3 files changed +17
-28
lines changed
Expand file tree Collapse file tree 3 files changed +17
-28
lines changed Original file line number Diff line number Diff line change 11import { YamlHandlerResponse } from "cdm/MashallModel" ;
2+ import { mockReset , mockDeep , DeepMockProxy } from "jest-mock-extended" ;
23import { parseYamlMock } from "mock/mockObsidianUtils" ;
34import 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) ;
1616describe ( "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" ) ;
Original file line number Diff line number Diff line change 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 */
45export 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" ,
Original file line number Diff line number Diff line change 22import faker from "@faker-js/faker" ;
33import React , { useRef , useLayoutEffect } from "react" ;
44import { randomColor } from "helpers/Colors" ;
5- import { DataTypes } from "helpers/Constants" ;
5+ import { DataTypes , DEFAULT_COLUMN_CONFIG } from "helpers/Constants" ;
66import { TableDataType , TableColumn , RowDataType } from "cdm/FolderModel" ;
77import { DatabaseColumn } from "cdm/DatabaseModel" ;
88import { 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 ;
You can’t perform that action at this time.
0 commit comments