Skip to content

Commit a863ab2

Browse files
committed
contrib: Update 'Using Obsidian API in tests' now that output is stable
1 parent e4af223 commit a863ab2

File tree

1 file changed

+3
-6
lines changed

1 file changed

+3
-6
lines changed

contributing/Testing/Using Obsidian API in tests.md

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,22 +13,19 @@ The Tasks plugin uses data created by the Obsidian API. The Obsidian API does no
1313
So we need a way to access Obsidian-generated data in our tests. This page tries to describe this mechanism.
1414

1515
1. [resources/sample_vaults/Tasks-Demo/Test Data](https://github.com/obsidian-tasks-group/obsidian-tasks/tree/main/resources/sample_vaults/Tasks-Demo/Test%20Data) contains representative samples Markdown files for different scenarios.
16-
2. The process described in [[#Test data creation sequence]] converts these files to matching TypeScript files in [tests/Obsidian/\_\_test_data\_\_](https://github.com/obsidian-tasks-group/obsidian-tasks/tree/main/tests/Obsidian/__test_data__).
16+
2. The process described in [[#Test data creation sequence]] converts these files to matching JSON files in [tests/Obsidian/\_\_test_data\_\_](https://github.com/obsidian-tasks-group/obsidian-tasks/tree/main/tests/Obsidian/__test_data__).
1717
3. So far the files that use this mechanism are [tests/Obsidian/Cache.test.ts](https://github.com/obsidian-tasks-group/obsidian-tasks/blob/main/tests/Obsidian/Cache.test.ts) and [tests/Scripting/TasksFile.test.ts](https://github.com/obsidian-tasks-group/obsidian-tasks/blob/main/tests/Scripting/TasksFile.test.ts). Refer to these files for examples.
1818

1919
## Test data creation sequence
2020

21-
If using this on an Obsidian version newer than the one in saved `tests/Obsidian/__test_data__/*.ts`, go to Settings → Files and links → Advanced → Rebuild vault cache.
21+
If using this on an Obsidian version newer than the one in saved `tests/Obsidian/__test_data__/*.json`, go to Settings → Files and links → Advanced → Rebuild vault cache.
2222

2323
- Create a sample markdown file in Tasks demo vault (root/Test Data/) with the simplest content to represent your test case. Choose a meaningful file name in snake case. See example in `Test Data/one_task.md`.
2424
- There is a Templater template that may help with creating a new file, for single-tasks cases: `resources/sample_vaults/Tasks-Demo/_meta/templates/Test Data file.md`.
2525
- Open any other note in the vault, just so that Templater will run.
2626
- The Templater plugin requires a note to be open. The script won't edit the file, so it doesn't matter which file you have open.
2727
- Run the command `Templater: Insert _meta/templates/convert_test_data_markdown_to_js.md`.
2828
- Or type the short-cut `Ctrl + Cmd + Alt + T` / `Ctrl + Ctrl + Alt + T`.
29-
- This will convert all the files `root/Test Data/*.md` to test functions in `tests/Obsidian/__test_data__/*.ts`.
30-
- Run `yarn lint:test-data` to standardise the formatting in the generated TypeScript files.
29+
- This will convert all the files `root/Test Data/*.md` to test functions in `tests/Obsidian/__test_data__/*.json`.
3130
- Use the data in the test with `readTasksFromSimulatedFile()`, the argument is the constant you created in the previous step.
3231
- Remember to commit the markdown file in the demo vault and the file with the simulated data.
33-
34-
> TODO: Make the order of values in the generated code stable.

0 commit comments

Comments
 (0)