generated from obsidianmd/obsidian-sample-plugin
-
-
Notifications
You must be signed in to change notification settings - Fork 239
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 #3214 from obsidian-tasks-group/refactor-layout-op…
…tion-parsing refactor: Reduce repetition of parsing of show/hide options
- Loading branch information
Showing
4 changed files
with
102 additions
and
67 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import { QueryLayoutOptions, parseQueryShowHideOptions } from '../../src/Layout/QueryLayoutOptions'; | ||
|
||
describe('parsing query show/hide layout options', () => { | ||
function parseOptionAndCheck(options: QueryLayoutOptions, option: string, hide: boolean) { | ||
const success = parseQueryShowHideOptions(options, option, hide); | ||
expect(success).toEqual(true); | ||
} | ||
|
||
const testCases: [string, keyof QueryLayoutOptions, boolean][] = [ | ||
// Alphabetical order | ||
['backlink', 'hideBacklinks', false], | ||
['edit button', 'hideEditButton', false], | ||
['postpone button', 'hidePostponeButton', false], | ||
['task count', 'hideTaskCount', false], | ||
['tree', 'hideTree', true], | ||
['urgency', 'hideUrgency', true], | ||
]; | ||
|
||
it.each(testCases)('should parse "%s" option', (option, property, hiddenByDefault) => { | ||
const options = new QueryLayoutOptions(); | ||
expect(options[property]).toBe(hiddenByDefault); | ||
|
||
parseOptionAndCheck(options, option, !hiddenByDefault); | ||
expect(options[property]).toEqual(!hiddenByDefault); | ||
|
||
parseOptionAndCheck(options, option, hiddenByDefault); | ||
expect(options[property]).toEqual(hiddenByDefault); | ||
}); | ||
}); |
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