Skip to content

Commit 4395e96

Browse files
committed
start of more tests
1 parent 7d1ae94 commit 4395e96

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+574
-197
lines changed

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Obsidian Meta Bind Changelog
22

3-
# Unreleased
3+
# 0.7.0
44

55
Breaking Changes
66

exampleVault/Input Fields/Suggester.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
fileSuggest: "[[Other/Example Notes/Example Note with Embeds.md|Example Note with Embeds]]"
3-
fileSuggest2: Example Note with Embeds
3+
fileSuggest2: Example Note with E
44
suggest: option 2
55
---
66

exampleVault/View Fields/View Field.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,3 +36,6 @@ Display Computed: `VIEW[{computed}][text()]`
3636
Display Computed as Markdown: `VIEW[{computed}][text(renderMarkdown)]`
3737
Loop Error: `VIEW[**{computed}**][text():distance]`
3838
Self Loop Error: `VIEW[**{computed}**][text():computed]`
39+
40+
41+
`VIEW['[[{file}|link]]'][text(renderMarkdown)]`

exampleVault/examples.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
slider1: 8
2+
slider1: 6
33
suggest: test
44
toggle1: false
55
Domestic_tasks:
@@ -9,7 +9,7 @@ Slept: 00:00
99
select: option c
1010
toggle: false
1111
nested:
12-
object: asdasdasd
12+
object: asd
1313
inlineSelect: 0
1414
---
1515

jest.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,5 @@ module.exports = {
33
testEnvironment: 'jsdom',
44
moduleDirectories: ['node_modules', 'src'],
55
verbose: true,
6-
setupFilesAfterEnv: ['<rootDir>/tests/CustomMatchers/jest.custom_matchers.setup.ts'],
6+
setupFilesAfterEnv: ['<rootDir>/tests/CustomMatchers/jest.custom_matchers.setup.ts', '<rootDir>/tests/jest.setup.js'],
77
};

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
"update-snapshots": "jest --updateSnapshot",
1414
"format": "prettier --write .",
1515
"lint": "eslint --max-warnings=0 src/**",
16+
"lint-fix": "eslint --max-warnings=0 --fix src/**",
1617
"types": "tsc -p \"./tsconfig.types.json\""
1718
},
1819
"keywords": [],

src/api/API.ts

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,10 @@ import {
1717
import { Signal } from '../utils/Signal';
1818
import { type BindTargetScope } from '../metadata/BindTargetScope';
1919
import { MetaBindTable } from '../metaBindTable/MetaBindTable';
20-
import { NewInputFieldFactory } from '../inputFields/NewInputFieldFactory';
20+
import { InputFieldFactory } from '../inputFields/InputFieldFactory';
2121
import { type JsViewFieldDeclaration, type UnvalidatedViewFieldDeclaration, type ViewFieldDeclaration } from '../parsers/viewFieldParser/ViewFieldDeclaration';
2222
import { ViewFieldFactory } from '../viewFields/ViewFieldFactory';
23+
import { getUUID } from '../utils/Utils';
2324

2425
export class API implements IAPI {
2526
public plugin: MetaBindPlugin;
@@ -30,7 +31,7 @@ export class API implements IAPI {
3031
public readonly viewFieldParser: ViewFieldDeclarationParser;
3132
public readonly bindTargetParser: BindTargetParser;
3233

33-
public readonly inputFieldFactory: NewInputFieldFactory;
34+
public readonly inputFieldFactory: InputFieldFactory;
3435
public readonly viewFieldFactory: ViewFieldFactory;
3536

3637
constructor(plugin: MetaBindPlugin) {
@@ -42,7 +43,7 @@ export class API implements IAPI {
4243
this.viewFieldParser = new ViewFieldDeclarationParser(this.plugin);
4344
this.bindTargetParser = new BindTargetParser(this.plugin);
4445

45-
this.inputFieldFactory = new NewInputFieldFactory(this.plugin);
46+
this.inputFieldFactory = new InputFieldFactory(this.plugin);
4647
this.viewFieldFactory = new ViewFieldFactory(this.plugin);
4748
}
4849

@@ -59,7 +60,7 @@ export class API implements IAPI {
5960

6061
const declaration = this.inputFieldParser.validateDeclaration(unvalidatedDeclaration);
6162

62-
const inputField = new InputFieldMDRC(containerEl, renderType, declaration, this.plugin, filePath, self.crypto.randomUUID());
63+
const inputField = new InputFieldMDRC(containerEl, renderType, declaration, this.plugin, filePath, getUUID());
6364
component.addChild(inputField);
6465

6566
return inputField;
@@ -79,7 +80,7 @@ export class API implements IAPI {
7980

8081
const declaration: InputFieldDeclaration = this.inputFieldParser.parseString(fullDeclaration, scope);
8182

82-
const inputField = new InputFieldMDRC(containerEl, renderType, declaration, this.plugin, filePath, self.crypto.randomUUID());
83+
const inputField = new InputFieldMDRC(containerEl, renderType, declaration, this.plugin, filePath, getUUID());
8384
component.addChild(inputField);
8485

8586
return inputField;
@@ -98,7 +99,7 @@ export class API implements IAPI {
9899

99100
const declaration: ViewFieldDeclaration = this.viewFieldParser.parseString(fullDeclaration);
100101

101-
const viewField = new ViewFieldMDRC(containerEl, renderType, declaration, this.plugin, filePath, self.crypto.randomUUID());
102+
const viewField = new ViewFieldMDRC(containerEl, renderType, declaration, this.plugin, filePath, getUUID());
102103
component.addChild(viewField);
103104

104105
return viewField;
@@ -117,14 +118,14 @@ export class API implements IAPI {
117118

118119
const declaration: JsViewFieldDeclaration = this.viewFieldParser.parseJsString(fullDeclaration);
119120

120-
const viewField = new JsViewFieldMDRC(containerEl, renderType, declaration, this.plugin, filePath, self.crypto.randomUUID());
121+
const viewField = new JsViewFieldMDRC(containerEl, renderType, declaration, this.plugin, filePath, getUUID());
121122
component.addChild(viewField);
122123

123124
return viewField;
124125
}
125126

126127
public createExcludedField(containerEl: HTMLElement, filePath: string, component: Component | MarkdownPostProcessorContext): ExcludedMDRC {
127-
const excludedField = new ExcludedMDRC(containerEl, RenderChildType.INLINE, this.plugin, filePath, self.crypto.randomUUID());
128+
const excludedField = new ExcludedMDRC(containerEl, RenderChildType.INLINE, this.plugin, filePath, getUUID());
128129
component.addChild(excludedField);
129130

130131
return excludedField;
@@ -143,7 +144,7 @@ export class API implements IAPI {
143144
* @param listenToChildren
144145
*/
145146
public listenToMetadata(signal: Signal<unknown>, filePath: string, metadataPath: string[], listenToChildren: boolean = false): () => void {
146-
const uuid = self.crypto.randomUUID();
147+
const uuid = getUUID();
147148

148149
const subscription = this.plugin.metadataManager.subscribe(uuid, signal, {
149150
filePath: filePath,
@@ -165,7 +166,7 @@ export class API implements IAPI {
165166
tableHead: string[],
166167
columns: (UnvalidatedInputFieldDeclaration | UnvalidatedViewFieldDeclaration)[],
167168
): MetaBindTable {
168-
const table = new MetaBindTable(containerEl, RenderChildType.INLINE, this.plugin, filePath, self.crypto.randomUUID(), bindTarget, tableHead, columns);
169+
const table = new MetaBindTable(containerEl, RenderChildType.INLINE, this.plugin, filePath, getUUID(), bindTarget, tableHead, columns);
169170
component.addChild(table);
170171

171172
return table;

src/inputFields/NewAbstractInputField.ts renamed to src/inputFields/AbstractInputField.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { type SvelteComponent } from 'svelte';
44
import { ComputedSignal, type Listener, Notifier } from '../utils/Signal';
55
import { InputFieldArgumentType } from '../parsers/inputFieldParser/InputFieldConfigs';
66

7-
export abstract class NewAbstractInputField<MetadataValueType, ComponentValueType> extends Notifier<MetadataValueType, Listener<MetadataValueType>> {
7+
export abstract class AbstractInputField<MetadataValueType, ComponentValueType> extends Notifier<MetadataValueType, Listener<MetadataValueType>> {
88
readonly renderChild: InputFieldMDRC;
99
readonly inputFieldComponent: InputFieldComponent<ComponentValueType>;
1010
readonly signal: ComputedSignal<unknown, MetadataValueType>;

src/inputFields/NewInputFieldFactory.ts renamed to src/inputFields/InputFieldFactory.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ export type NewInputField =
3939
| DateIPF
4040
| TimeIPF;
4141

42-
export class NewInputFieldFactory {
42+
export class InputFieldFactory {
4343
plugin: IPlugin;
4444

4545
constructor(plugin: IPlugin) {

src/inputFields/fields/Date/DateIPF.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
import { NewAbstractInputField } from '../../NewAbstractInputField';
1+
import { AbstractInputField } from '../../AbstractInputField';
22
import { type moment } from 'obsidian';
33
import { type SvelteComponent } from 'svelte';
44
import { type InputFieldMDRC } from '../../../renderChildren/InputFieldMDRC';
55
import { parseUnknownToString } from '../../../utils/Utils';
66
import { DateParser } from '../../../parsers/DateParser';
77
import DateComponent from './DateComponent.svelte';
88

9-
export class DateIPF extends NewAbstractInputField<string, moment.Moment> {
9+
export class DateIPF extends AbstractInputField<string, moment.Moment> {
1010
constructor(renderChild: InputFieldMDRC) {
1111
super(renderChild);
1212
}

0 commit comments

Comments
 (0)