generated from obsidianmd/obsidian-sample-plugin
-
-
Notifications
You must be signed in to change notification settings - Fork 235
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2179 from obsidian-tasks-group/support-variables
feat: Support variables in custom filters and groups
- Loading branch information
Showing
17 changed files
with
198 additions
and
44 deletions.
There are no files selected for viewing
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
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,31 @@ | ||
import { diff } from 'jest-diff'; | ||
import { evaluateExpression, parseExpression } from '../../src/Scripting/Expression'; | ||
|
||
declare global { | ||
namespace jest { | ||
interface Matchers<R> { | ||
toEvaluateAs(expected: any): CustomMatcherResult; | ||
} | ||
} | ||
} | ||
|
||
// Based on https://stackoverflow.com/a/60229956/104370 | ||
export function toEvaluateAs(instruction: string, expected: any): jest.CustomMatcherResult { | ||
const functionOrError = parseExpression([], instruction); | ||
expect(functionOrError.queryComponent).not.toBeUndefined(); | ||
const received = evaluateExpression(functionOrError.queryComponent!, []); | ||
|
||
const pass: boolean = received === expected; | ||
const expectedAsText = expected.toString(); | ||
const receivedAsText = received ? received.toString() : 'null'; | ||
|
||
const message: () => string = () => | ||
pass | ||
? `Expression result should not be ${expectedAsText}` | ||
: `Expression result is not the same as expected: ${diff(expectedAsText, receivedAsText)}`; | ||
|
||
return { | ||
message, | ||
pass, | ||
}; | ||
} |
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
11 changes: 11 additions & 0 deletions
11
tests/Scripting/Expression.test.Expression_returns_and_functions.approved.md
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,11 @@ | ||
<!-- placeholder to force blank line before included text --> | ||
|
||
~~~text | ||
return 42 => 42 | ||
const x = 1 + 1; return x * x => 4 | ||
if (1 === 1) { return "yes"; } else { return "no" } => 'yes' | ||
function f(value) { if (value === 1 ) { return "yes"; } else { return "no"; } } return f(1) => 'yes' | ||
~~~ | ||
|
||
|
||
<!-- placeholder to force blank line after included text --> |
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
5 changes: 3 additions & 2 deletions
5
...ring/CustomFilteringExamples.test.file_properties_task.heading_docs.approved.md
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
Oops, something went wrong.