simontc_obsidian-note-autoc.../tests/Query.test.ts

29 lines
956 B
TypeScript
Raw Permalink Normal View History

import 'jest-extended'
import {Fake} from "./Fake"
import {ObsidianFolderPath} from "../src/core/paths/ObsidianFolderPath"
import {ObsidianFilePath} from "../src/core/paths/ObsidianFilePath"
import {ExistingNoteSuggestion} from "../src/core/suggestions/NoteSuggestion"
2022-09-17 11:02:44 +00:00
import {Query} from "../src/core/queries/Query"
describe('topFolderCheck', function () {
test('ignores word cases', () => {
const relativeTopFolders = [
new ObsidianFolderPath('FOLDER')
]
const settings = Fake.Settings
settings.relativeTopFolders = relativeTopFolders
const query = 'note'
const queryPath = new ObsidianFilePath(query)
const currentFile = Fake.File('folder1/folder2/my markdown file')
const context = Fake.EditorSuggestionContext(query).withFile(currentFile)
2022-09-17 11:02:44 +00:00
const matcher = Query.topFolderCheck(queryPath, context, settings)
const result = matcher(new ExistingNoteSuggestion('folder1/folder2/some note'))
expect(result).toBe(true)
})
})