-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f53d72e
commit 3c7ce0f
Showing
19 changed files
with
184 additions
and
132,604 deletions.
There are no files selected for viewing
132,509 changes: 0 additions & 132,509 deletions
132,509
.vault/.obsidian/plugins/data-entry/main.js
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/home/wayne/code/obsidian-plugin-data-entry/packages/data-entry/main.js |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/home/wayne/code/obsidian-plugin-data-entry/packages/data-entry/manifest.json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from '@waynevanson/obsidian-mocks'; |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/dist |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,18 @@ | ||
{ | ||
"name": "@waynevanson/obsidian-mocks" | ||
"name": "@waynevanson/obsidian-mocks", | ||
"main": "dist/index.js", | ||
"types": "dist/index.d.ts", | ||
"type": "commonjs", | ||
"scripts": { | ||
"build": "tsc" | ||
}, | ||
"devDependencies": { | ||
"@types/jest": "^29.5.3", | ||
"@types/node": "^18.17.3", | ||
"jest": "^29.6.2", | ||
"obsidian": "^1.4.0", | ||
"ts-jest": "^29.1.1", | ||
"ts-node": "^10.9.1", | ||
"typescript": "4.7.4" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
export * from './events'; | ||
export * from './vault'; | ||
|
||
import 'obsidian'; | ||
import { Directory } from './data-adapter'; | ||
|
||
declare module 'obsidian' { | ||
export interface EventRef { | ||
mockName: string; | ||
mockCallback: (...data: Array<unknown>) => void; | ||
} | ||
|
||
export interface MockVaultParams { | ||
root: Directory; | ||
} | ||
|
||
export function createVaultMock(params: MockVaultParams): Vault; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
import { Events } from './events'; | ||
import { createDataAdapter } from './data-adapter'; | ||
import type { DataAdapter, MockVaultParams } from 'obsidian'; | ||
|
||
export function createVaultMock(params: MockVaultParams): Vault { | ||
return new Vault(params); | ||
} | ||
|
||
export class Vault extends Events { | ||
public adapter: ReturnType<typeof createDataAdapter> & DataAdapter; | ||
|
||
constructor(params: MockVaultParams) { | ||
super(); | ||
this.adapter = createDataAdapter(params.root); | ||
} | ||
|
||
getAbstractFileByPath(this: this, path: string): TAbstractFile | null { | ||
const exists = this.adapter.existsSync(path); | ||
if (!exists) return null; | ||
else { | ||
return new TFile({ | ||
name: path, | ||
path, | ||
vault: this, | ||
parent: null, | ||
}); | ||
} | ||
} | ||
|
||
async read(this: this, file: TFile) { | ||
return this.adapter.read(file.path); | ||
} | ||
} | ||
|
||
type Properties<T> = { [P in keyof T]: T[P] }; | ||
|
||
export abstract class TAbstractFile { | ||
vault!: Vault; | ||
path!: string; | ||
name!: string; | ||
parent!: TFolder | null; | ||
|
||
constructor(properties: Properties<TAbstractFile>) { | ||
Object.assign(this, properties); | ||
} | ||
} | ||
|
||
export class TFolder extends TAbstractFile { | ||
children!: TAbstractFile[]; | ||
|
||
constructor(properties: Properties<TFolder>) { | ||
super(properties); | ||
Object.assign(this, properties); | ||
} | ||
|
||
isRoot(): boolean { | ||
return this.parent == null; | ||
} | ||
} | ||
|
||
export class TFile extends TAbstractFile { | ||
constructor(properties: Properties<TFile>) { | ||
super(properties); | ||
Object.assign(this, properties); | ||
} | ||
|
||
// get basename(): string { | ||
// return ''; | ||
// } | ||
|
||
// get stat(): FileStats { | ||
// return; | ||
// } | ||
|
||
// get extension(): string { | ||
// return; | ||
// } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
{ | ||
"compilerOptions": { | ||
"strict": true, | ||
"module": "commonjs", | ||
"moduleResolution": "node", | ||
"target": "es6", | ||
"strictNullChecks": true, | ||
"outDir": "dist", | ||
"declaration": true, | ||
"esModuleInterop": true | ||
}, | ||
"include": ["src"] | ||
} |
Oops, something went wrong.