Skip to content

Commit

Permalink
test: - Add tests using the Obsidian representation of callouts
Browse files Browse the repository at this point in the history
2 tests that use labelled callouts are failing, due to an Obsidian bug. See #2863
  • Loading branch information
claremacrae committed Jun 21, 2024
1 parent b0175ec commit 72dabb7
Showing 1 changed file with 126 additions and 0 deletions.
126 changes: 126 additions & 0 deletions tests/Obsidian/Cache.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,11 @@ import { inheritance_task_listitem_mixed_grandchildren } from './__test_data__/i
import { inheritance_task_listitem_task } from './__test_data__/inheritance_task_listitem_task';
import { inheritance_task_mixed_children } from './__test_data__/inheritance_task_mixed_children';
import { one_task } from './__test_data__/one_task';
import { callouts_nested_issue_2890_labelled } from './__test_data__/callouts_nested_issue_2890_labelled';
import { callout } from './__test_data__/callout';
import { callout_labelled } from './__test_data__/callout_labelled';
import { callout_custom } from './__test_data__/callout_custom';
import { callouts_nested_issue_2890_unlabelled } from './__test_data__/callouts_nested_issue_2890_unlabelled';

window.moment = moment;

Expand Down Expand Up @@ -470,4 +475,125 @@ describe('cache', () => {
"
`);
});

it('callout', () => {
const tasks = readTasksFromSimulatedFile(callout);
expect(callout.fileContents).toMatchInlineSnapshot(`
"# callout
> [!todo]
> - [ ] #task Task in 'callout'
> - [ ] #task Task indented in 'callout'
\`\`\`tasks
not done
path includes {{query.file.path}}
\`\`\`
"
`);
expect(printRoots(tasks)).toMatchInlineSnapshot(`
"> - [ ] #task Task in 'callout' : Task
> - [ ] #task Task indented in 'callout' : Task
"
`);
expect(tasks.length).toEqual(2);
});

it('callout_custom', () => {
const tasks = readTasksFromSimulatedFile(callout_custom);
expect(callout_custom.fileContents).toMatchInlineSnapshot(`
"# callout_custom
> [!callout_custom]
> - [ ] #task Task in 'callout_custom'
> - [ ] #task Task indented in 'callout_custom'
\`\`\`tasks
not done
path includes {{query.file.path}}
\`\`\`
"
`);
expect(printRoots(tasks)).toMatchInlineSnapshot(`
"> - [ ] #task Task in 'callout_custom' : Task
> - [ ] #task Task indented in 'callout_custom' : Task
"
`);
expect(tasks.length).toEqual(2);
});

it.failing('callout_labelled', () => {
const tasks = readTasksFromSimulatedFile(callout_labelled);
expect(callout_labelled.fileContents).toMatchInlineSnapshot(`
"# callout_labelled
> [!todo] callout_labelled
> - [ ] #task Task in 'callout_labelled'
> - [ ] #task Task indented in 'callout_labelled'
\`\`\`tasks
not done
path includes {{query.file.path}}
\`\`\`
"
`);
expect(printRoots(tasks)).toMatchInlineSnapshot(`
"> - [ ] #task Task indented in 'callout_labelled' : Task
"
`);
expect(tasks.length).toEqual(2);
});

it('callouts_nested_issue_2890_unlabelled', () => {
const tasks = readTasksFromSimulatedFile(callouts_nested_issue_2890_unlabelled);
expect(callouts_nested_issue_2890_unlabelled.fileContents).toMatchInlineSnapshot(`
" > [!Calendar]+
>> [!Check]+
>>> [!Attention]+
>>> Some stuff goes here
>>> - [ ] #task Correction1
>>> - [ ] #task Correction2
>>> - [ ] #task Correction3
>>> - [ ] #task Correction4
\`\`\`tasks
not done
path includes {{query.file.path}}
\`\`\`
"
`);
expect(printRoots(tasks)).toMatchInlineSnapshot(`
">>> - [ ] #task Correction1 : Task
>>> - [ ] #task Correction2 : Task
>>> - [ ] #task Correction3 : Task
>>> - [ ] #task Correction4 : Task
"
`);
expect(tasks.length).toEqual(4);
});

it.failing('callouts_nested_issue_2890_labelled', () => {
const tasks = readTasksFromSimulatedFile(callouts_nested_issue_2890_labelled);
expect(callouts_nested_issue_2890_labelled.fileContents).toMatchInlineSnapshot(`
" > [!Calendar]+ MONTH
>> [!Check]+ GROUP
>>> [!Attention]+ Correction TITLE
>>> Some stuff goes here
>>> - [ ] #task Correction1
>>> - [ ] #task Correction2
>>> - [ ] #task Correction3
>>> - [ ] #task Correction4
\`\`\`tasks
not done
path includes {{query.file.path}}
\`\`\`
"
`);
expect(printRoots(tasks)).toMatchInlineSnapshot(`
">>> - [ ] #task Correction4 : Task
"
`);
expect(tasks.length).toEqual(4);
});
});

0 comments on commit 72dabb7

Please sign in to comment.