From a948d10512bd905d09556886d6341a66e12af258 Mon Sep 17 00:00:00 2001 From: Bruno Charest Date: Fri, 3 Oct 2025 14:34:10 -0400 Subject: [PATCH] refactor: replace toBeTrue/toBeFalse with toBe(true/false) in test assertions --- src/app/graph/graph.selectors.spec.ts | 16 +++++----- src/app/graph/group-query.parser.spec.ts | 40 ++++++++++++------------ src/core/search/search-parser.spec.ts | 16 +++++----- src/services/markdown.service.spec.ts | 16 +++++----- vault/.obsidian/graph.json | 22 ++++++++----- vault/.obsidian/graph.json.bak | 2 +- 6 files changed, 60 insertions(+), 52 deletions(-) diff --git a/src/app/graph/graph.selectors.spec.ts b/src/app/graph/graph.selectors.spec.ts index 63d6278..6dbd54c 100644 --- a/src/app/graph/graph.selectors.spec.ts +++ b/src/app/graph/graph.selectors.spec.ts @@ -61,7 +61,7 @@ describe('GraphSelectors', () => { const result = filtered(); expect(result.nodes.length).toBe(3); // nodes 1, 2, 5 have tags - expect(result.nodes.every(n => n.tags.length > 0)).toBeTrue(); + expect(result.nodes.every(n => n.tags.length > 0)).toBe(true); }); it('should filter by attachments', () => { @@ -81,7 +81,7 @@ describe('GraphSelectors', () => { const result = filtered(); expect(result.nodes.length).toBe(4); // node 4 has exists: false - expect(result.nodes.every(n => n.exists)).toBeTrue(); + expect(result.nodes.every(n => n.exists)).toBe(true); }); it('should filter orphans', () => { @@ -91,7 +91,7 @@ describe('GraphSelectors', () => { const result = filtered(); // Node 4 is orphan (no links) - expect(result.nodes.every(n => n.id !== '4')).toBeTrue(); + expect(result.nodes.every(n => n.id !== '4')).toBe(true); }); it('should prune broken links after filtering', () => { @@ -118,8 +118,8 @@ describe('GraphSelectors', () => { const node1 = result.nodes.find(n => n.id === '1'); const node2 = result.nodes.find(n => n.id === '2'); - expect(node1?.color.includes('255, 0, 0')).toBeTrue(); // Red for markdown - expect(node2?.color.includes('0, 255, 0')).toBeTrue(); // Green for test + expect(node1?.color.includes('255, 0, 0')).toBe(true); // Red for markdown + expect(node2?.color.includes('0, 255, 0')).toBe(true); // Green for test }); it('should mark orphan status correctly', () => { @@ -129,7 +129,7 @@ describe('GraphSelectors', () => { const result = filtered(); const node4 = result.nodes.find(n => n.id === '4'); - expect(node4?.isOrphan).toBeTrue(); + expect(node4?.isOrphan).toBe(true); expect(node4?.degree).toBe(0); }); @@ -202,8 +202,8 @@ describe('GraphSelectors', () => { const legend = createGroupLegend(filtered, config, focusedGroup); const items = legend(); - expect(items[0].active).toBeTrue(); - expect(items[1].active).toBeFalse(); + expect(items[0].active).toBe(true); + expect(items[1].active).toBe(false); }); }); }); diff --git a/src/app/graph/group-query.parser.spec.ts b/src/app/graph/group-query.parser.spec.ts index 12c69bf..1a35b1f 100644 --- a/src/app/graph/group-query.parser.spec.ts +++ b/src/app/graph/group-query.parser.spec.ts @@ -56,27 +56,27 @@ describe('GroupQueryParser', () => { it('should match node with tag', () => { const node = createNode({ tags: ['markdown', 'note'] }); const query = parseGroupQuery('tag:#markdown')!; - expect(nodeMatchesQuery(node, query)).toBeTrue(); + expect(nodeMatchesQuery(node, query)).toBe(true); }); it('should match tag case-insensitively', () => { const node = createNode({ tags: ['Markdown', 'Test'] }); const query = parseGroupQuery('tag:#markdown')!; - expect(nodeMatchesQuery(node, query)).toBeTrue(); + expect(nodeMatchesQuery(node, query)).toBe(true); }); it('should handle tags with or without hash', () => { const node = createNode({ tags: ['#markdown'] }); const query1 = parseGroupQuery('tag:#markdown')!; const query2 = parseGroupQuery('tag:markdown')!; - expect(nodeMatchesQuery(node, query1)).toBeTrue(); - expect(nodeMatchesQuery(node, query2)).toBeTrue(); + expect(nodeMatchesQuery(node, query1)).toBe(true); + expect(nodeMatchesQuery(node, query2)).toBe(true); }); it('should not match node without tag', () => { const node = createNode({ tags: ['other'] }); const query = parseGroupQuery('tag:#markdown')!; - expect(nodeMatchesQuery(node, query)).toBeFalse(); + expect(nodeMatchesQuery(node, query)).toBe(false); }); }); @@ -85,20 +85,20 @@ describe('GroupQueryParser', () => { const node1 = createNode({ title: 'My Test Note' }); const node2 = createNode({ path: 'testing/note.md' }); const query = parseGroupQuery('file:test')!; - expect(nodeMatchesQuery(node1, query)).toBeTrue(); - expect(nodeMatchesQuery(node2, query)).toBeTrue(); + expect(nodeMatchesQuery(node1, query)).toBe(true); + expect(nodeMatchesQuery(node2, query)).toBe(true); }); it('should match case-insensitively', () => { const node = createNode({ title: 'TEST' }); const query = parseGroupQuery('file:test')!; - expect(nodeMatchesQuery(node, query)).toBeTrue(); + expect(nodeMatchesQuery(node, query)).toBe(true); }); it('should not match when text not found', () => { const node = createNode({ title: 'Note', path: 'folder/note.md' }); const query = parseGroupQuery('file:xyz')!; - expect(nodeMatchesQuery(node, query)).toBeFalse(); + expect(nodeMatchesQuery(node, query)).toBe(false); }); }); @@ -108,34 +108,34 @@ describe('GroupQueryParser', () => { const node2 = createNode({ path: 'folder/subfolder/note.md' }); const q1 = parseGroupQuery('path:folder')!; const q2 = parseGroupQuery('path:folder/subfolder')!; - expect(nodeMatchesQuery(node1, q1)).toBeTrue(); - expect(nodeMatchesQuery(node2, q2)).toBeTrue(); + expect(nodeMatchesQuery(node1, q1)).toBe(true); + expect(nodeMatchesQuery(node2, q2)).toBe(true); }); it('should match with trailing slash', () => { const node = createNode({ path: 'folder/note.md' }); const query = parseGroupQuery('path:folder/')!; - expect(nodeMatchesQuery(node, query)).toBeTrue(); + expect(nodeMatchesQuery(node, query)).toBe(true); }); it('should respect case-insensitivity and not partially match', () => { const node1 = createNode({ path: 'Folder/note.md' }); const node2 = createNode({ path: 'foldertest/note.md' }); const q = parseGroupQuery('path:folder')!; - expect(nodeMatchesQuery(node1, q)).toBeTrue(); - expect(nodeMatchesQuery(node2, q)).toBeFalse(); + expect(nodeMatchesQuery(node1, q)).toBe(true); + expect(nodeMatchesQuery(node2, q)).toBe(false); }); }); }); describe('isValidQuery', () => { it('should validate and reject queries correctly', () => { - expect(isValidQuery('tag:#test')).toBeTrue(); - expect(isValidQuery('file:test')).toBeTrue(); - expect(isValidQuery('path:folder')).toBeTrue(); - expect(isValidQuery('')).toBeFalse(); - expect(isValidQuery('invalid')).toBeFalse(); - expect(isValidQuery('tag:')).toBeFalse(); + expect(isValidQuery('tag:#test')).toBe(true); + expect(isValidQuery('file:test')).toBe(true); + expect(isValidQuery('path:folder')).toBe(true); + expect(isValidQuery('')).toBe(false); + expect(isValidQuery('invalid')).toBe(false); + expect(isValidQuery('tag:')).toBe(false); }); }); }); diff --git a/src/core/search/search-parser.spec.ts b/src/core/search/search-parser.spec.ts index a4a2283..a11a35a 100644 --- a/src/core/search/search-parser.spec.ts +++ b/src/core/search/search-parser.spec.ts @@ -21,37 +21,37 @@ const createContext = (overrides: Partial = {}): SearchContext => describe('Search Parser', () => { it('parseSearchQuery marks empty query as empty', () => { const parsed = parseSearchQuery(''); - expect(parsed.isEmpty).toBeTrue(); + expect(parsed.isEmpty).toBe(true); expect(parsed.ast.type).toBe('group'); }); it('parseSearchQuery handles basic text queries', () => { const parsed = parseSearchQuery('hello world'); - expect(parsed.isEmpty).toBeFalse(); + expect(parsed.isEmpty).toBe(false); expect(parsed.ast.type).toBe('group'); }); it('parseSearchQuery handles operators', () => { const parsed = parseSearchQuery('path:notes/ tag:#tag file:example'); - expect(parsed.isEmpty).toBeFalse(); + expect(parsed.isEmpty).toBe(false); }); it('queryToPredicate matches simple text', () => { const predicate = queryToPredicate(parseSearchQuery('hello')); - expect(predicate(createContext())).toBeTrue(); + expect(predicate(createContext())).toBe(true); }); it('queryToPredicate respects negation', () => { const predicate = queryToPredicate(parseSearchQuery('-deprecated')); - expect(predicate(createContext())).toBeTrue(); - expect(predicate(createContext({ content: 'deprecated feature' }))).toBeFalse(); + expect(predicate(createContext())).toBe(true); + expect(predicate(createContext({ content: 'deprecated feature' }))).toBe(false); }); it('queryToPredicate matches task scopes', () => { const todoPredicate = queryToPredicate(parseSearchQuery('task-todo:Call')); const donePredicate = queryToPredicate(parseSearchQuery('task-done:Review')); - expect(todoPredicate(createContext())).toBeTrue(); - expect(donePredicate(createContext())).toBeTrue(); + expect(todoPredicate(createContext())).toBe(true); + expect(donePredicate(createContext())).toBe(true); }); it('detectQueryType recognises path prefix', () => { diff --git a/src/services/markdown.service.spec.ts b/src/services/markdown.service.spec.ts index 270a9c1..9760bf0 100644 --- a/src/services/markdown.service.spec.ts +++ b/src/services/markdown.service.spec.ts @@ -10,9 +10,9 @@ describe('MarkdownService', () => { it('renders tables with inline markdown content', () => { const html = render(`| Syntax | Description |\n| --- | --- |\n| **bold** | \`code\` |\n`); - expect(html.includes('bold')).toBeTrue(); - expect(html.includes('code')).toBeTrue(); + expect(html.includes('bold')).toBe(true); + expect(html.includes('code')).toBe(true); }); it('applies alignment markers for columns', () => { @@ -21,15 +21,15 @@ describe('MarkdownService', () => { const hasLeft = /text-align:\s*left\b/.test(html) || /align=\"left\"/.test(html); const hasCenter = /text-align:\s*center\b/.test(html) || /align=\"center\"/.test(html); const hasRight = /text-align:\s*right\b/.test(html) || /align=\"right\"/.test(html); - expect(hasLeft).toBeTrue(); - expect(hasCenter).toBeTrue(); - expect(hasRight).toBeTrue(); + expect(hasLeft).toBe(true); + expect(hasCenter).toBe(true); + expect(hasRight).toBe(true); }); it('falls back gracefully when separator row is malformed', () => { const html = render(`| A | B |\n| -- | |\n| 1 | 2 |\n`); - expect(html.includes('
')).toBeFalse(); - expect(html.includes('| A | B |')).toBeTrue(); + expect(html.includes('
')).toBe(false); + expect(html.includes('| A | B |')).toBe(true); }); }); diff --git a/vault/.obsidian/graph.json b/vault/.obsidian/graph.json index 81dd15a..01be3a3 100644 --- a/vault/.obsidian/graph.json +++ b/vault/.obsidian/graph.json @@ -1,18 +1,26 @@ { - "collapse-filter": false, + "collapse-filter": true, "search": "", "showTags": false, "showAttachments": false, - "hideUnresolved": true, - "showOrphans": true, - "collapse-color-groups": false, - "colorGroups": [], - "collapse-display": false, + "hideUnresolved": false, + "showOrphans": false, + "collapse-color-groups": true, + "colorGroups": [ + { + "query": "tag:test", + "color": { + "a": 1, + "rgb": 11657324 + } + } + ], + "collapse-display": true, "showArrow": false, "textFadeMultiplier": 0, "nodeSizeMultiplier": 1, "lineSizeMultiplier": 1, - "collapse-forces": false, + "collapse-forces": true, "centerStrength": 0.5, "repelStrength": 10, "linkStrength": 1, diff --git a/vault/.obsidian/graph.json.bak b/vault/.obsidian/graph.json.bak index 5b58ab0..81dd15a 100644 --- a/vault/.obsidian/graph.json.bak +++ b/vault/.obsidian/graph.json.bak @@ -3,7 +3,7 @@ "search": "", "showTags": false, "showAttachments": false, - "hideUnresolved": false, + "hideUnresolved": true, "showOrphans": true, "collapse-color-groups": false, "colorGroups": [],