refactor: replace toBeTrue/toBeFalse with toBe(true/false) in test assertions

This commit is contained in:
Bruno Charest 2025-10-03 14:34:10 -04:00
parent 77ced60d7c
commit a948d10512
6 changed files with 60 additions and 52 deletions

View File

@ -61,7 +61,7 @@ describe('GraphSelectors', () => {
const result = filtered(); const result = filtered();
expect(result.nodes.length).toBe(3); // nodes 1, 2, 5 have tags 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', () => { it('should filter by attachments', () => {
@ -81,7 +81,7 @@ describe('GraphSelectors', () => {
const result = filtered(); const result = filtered();
expect(result.nodes.length).toBe(4); // node 4 has exists: false 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', () => { it('should filter orphans', () => {
@ -91,7 +91,7 @@ describe('GraphSelectors', () => {
const result = filtered(); const result = filtered();
// Node 4 is orphan (no links) // 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', () => { it('should prune broken links after filtering', () => {
@ -118,8 +118,8 @@ describe('GraphSelectors', () => {
const node1 = result.nodes.find(n => n.id === '1'); const node1 = result.nodes.find(n => n.id === '1');
const node2 = result.nodes.find(n => n.id === '2'); const node2 = result.nodes.find(n => n.id === '2');
expect(node1?.color.includes('255, 0, 0')).toBeTrue(); // Red for markdown expect(node1?.color.includes('255, 0, 0')).toBe(true); // Red for markdown
expect(node2?.color.includes('0, 255, 0')).toBeTrue(); // Green for test expect(node2?.color.includes('0, 255, 0')).toBe(true); // Green for test
}); });
it('should mark orphan status correctly', () => { it('should mark orphan status correctly', () => {
@ -129,7 +129,7 @@ describe('GraphSelectors', () => {
const result = filtered(); const result = filtered();
const node4 = result.nodes.find(n => n.id === '4'); const node4 = result.nodes.find(n => n.id === '4');
expect(node4?.isOrphan).toBeTrue(); expect(node4?.isOrphan).toBe(true);
expect(node4?.degree).toBe(0); expect(node4?.degree).toBe(0);
}); });
@ -202,8 +202,8 @@ describe('GraphSelectors', () => {
const legend = createGroupLegend(filtered, config, focusedGroup); const legend = createGroupLegend(filtered, config, focusedGroup);
const items = legend(); const items = legend();
expect(items[0].active).toBeTrue(); expect(items[0].active).toBe(true);
expect(items[1].active).toBeFalse(); expect(items[1].active).toBe(false);
}); });
}); });
}); });

View File

@ -56,27 +56,27 @@ describe('GroupQueryParser', () => {
it('should match node with tag', () => { it('should match node with tag', () => {
const node = createNode({ tags: ['markdown', 'note'] }); const node = createNode({ tags: ['markdown', 'note'] });
const query = parseGroupQuery('tag:#markdown')!; const query = parseGroupQuery('tag:#markdown')!;
expect(nodeMatchesQuery(node, query)).toBeTrue(); expect(nodeMatchesQuery(node, query)).toBe(true);
}); });
it('should match tag case-insensitively', () => { it('should match tag case-insensitively', () => {
const node = createNode({ tags: ['Markdown', 'Test'] }); const node = createNode({ tags: ['Markdown', 'Test'] });
const query = parseGroupQuery('tag:#markdown')!; const query = parseGroupQuery('tag:#markdown')!;
expect(nodeMatchesQuery(node, query)).toBeTrue(); expect(nodeMatchesQuery(node, query)).toBe(true);
}); });
it('should handle tags with or without hash', () => { it('should handle tags with or without hash', () => {
const node = createNode({ tags: ['#markdown'] }); const node = createNode({ tags: ['#markdown'] });
const query1 = parseGroupQuery('tag:#markdown')!; const query1 = parseGroupQuery('tag:#markdown')!;
const query2 = parseGroupQuery('tag:markdown')!; const query2 = parseGroupQuery('tag:markdown')!;
expect(nodeMatchesQuery(node, query1)).toBeTrue(); expect(nodeMatchesQuery(node, query1)).toBe(true);
expect(nodeMatchesQuery(node, query2)).toBeTrue(); expect(nodeMatchesQuery(node, query2)).toBe(true);
}); });
it('should not match node without tag', () => { it('should not match node without tag', () => {
const node = createNode({ tags: ['other'] }); const node = createNode({ tags: ['other'] });
const query = parseGroupQuery('tag:#markdown')!; 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 node1 = createNode({ title: 'My Test Note' });
const node2 = createNode({ path: 'testing/note.md' }); const node2 = createNode({ path: 'testing/note.md' });
const query = parseGroupQuery('file:test')!; const query = parseGroupQuery('file:test')!;
expect(nodeMatchesQuery(node1, query)).toBeTrue(); expect(nodeMatchesQuery(node1, query)).toBe(true);
expect(nodeMatchesQuery(node2, query)).toBeTrue(); expect(nodeMatchesQuery(node2, query)).toBe(true);
}); });
it('should match case-insensitively', () => { it('should match case-insensitively', () => {
const node = createNode({ title: 'TEST' }); const node = createNode({ title: 'TEST' });
const query = parseGroupQuery('file: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', () => { it('should not match when text not found', () => {
const node = createNode({ title: 'Note', path: 'folder/note.md' }); const node = createNode({ title: 'Note', path: 'folder/note.md' });
const query = parseGroupQuery('file:xyz')!; 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 node2 = createNode({ path: 'folder/subfolder/note.md' });
const q1 = parseGroupQuery('path:folder')!; const q1 = parseGroupQuery('path:folder')!;
const q2 = parseGroupQuery('path:folder/subfolder')!; const q2 = parseGroupQuery('path:folder/subfolder')!;
expect(nodeMatchesQuery(node1, q1)).toBeTrue(); expect(nodeMatchesQuery(node1, q1)).toBe(true);
expect(nodeMatchesQuery(node2, q2)).toBeTrue(); expect(nodeMatchesQuery(node2, q2)).toBe(true);
}); });
it('should match with trailing slash', () => { it('should match with trailing slash', () => {
const node = createNode({ path: 'folder/note.md' }); const node = createNode({ path: 'folder/note.md' });
const query = parseGroupQuery('path:folder/')!; 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', () => { it('should respect case-insensitivity and not partially match', () => {
const node1 = createNode({ path: 'Folder/note.md' }); const node1 = createNode({ path: 'Folder/note.md' });
const node2 = createNode({ path: 'foldertest/note.md' }); const node2 = createNode({ path: 'foldertest/note.md' });
const q = parseGroupQuery('path:folder')!; const q = parseGroupQuery('path:folder')!;
expect(nodeMatchesQuery(node1, q)).toBeTrue(); expect(nodeMatchesQuery(node1, q)).toBe(true);
expect(nodeMatchesQuery(node2, q)).toBeFalse(); expect(nodeMatchesQuery(node2, q)).toBe(false);
}); });
}); });
}); });
describe('isValidQuery', () => { describe('isValidQuery', () => {
it('should validate and reject queries correctly', () => { it('should validate and reject queries correctly', () => {
expect(isValidQuery('tag:#test')).toBeTrue(); expect(isValidQuery('tag:#test')).toBe(true);
expect(isValidQuery('file:test')).toBeTrue(); expect(isValidQuery('file:test')).toBe(true);
expect(isValidQuery('path:folder')).toBeTrue(); expect(isValidQuery('path:folder')).toBe(true);
expect(isValidQuery('')).toBeFalse(); expect(isValidQuery('')).toBe(false);
expect(isValidQuery('invalid')).toBeFalse(); expect(isValidQuery('invalid')).toBe(false);
expect(isValidQuery('tag:')).toBeFalse(); expect(isValidQuery('tag:')).toBe(false);
}); });
}); });
}); });

View File

@ -21,37 +21,37 @@ const createContext = (overrides: Partial<SearchContext> = {}): SearchContext =>
describe('Search Parser', () => { describe('Search Parser', () => {
it('parseSearchQuery marks empty query as empty', () => { it('parseSearchQuery marks empty query as empty', () => {
const parsed = parseSearchQuery(''); const parsed = parseSearchQuery('');
expect(parsed.isEmpty).toBeTrue(); expect(parsed.isEmpty).toBe(true);
expect(parsed.ast.type).toBe('group'); expect(parsed.ast.type).toBe('group');
}); });
it('parseSearchQuery handles basic text queries', () => { it('parseSearchQuery handles basic text queries', () => {
const parsed = parseSearchQuery('hello world'); const parsed = parseSearchQuery('hello world');
expect(parsed.isEmpty).toBeFalse(); expect(parsed.isEmpty).toBe(false);
expect(parsed.ast.type).toBe('group'); expect(parsed.ast.type).toBe('group');
}); });
it('parseSearchQuery handles operators', () => { it('parseSearchQuery handles operators', () => {
const parsed = parseSearchQuery('path:notes/ tag:#tag file:example'); const parsed = parseSearchQuery('path:notes/ tag:#tag file:example');
expect(parsed.isEmpty).toBeFalse(); expect(parsed.isEmpty).toBe(false);
}); });
it('queryToPredicate matches simple text', () => { it('queryToPredicate matches simple text', () => {
const predicate = queryToPredicate(parseSearchQuery('hello')); const predicate = queryToPredicate(parseSearchQuery('hello'));
expect(predicate(createContext())).toBeTrue(); expect(predicate(createContext())).toBe(true);
}); });
it('queryToPredicate respects negation', () => { it('queryToPredicate respects negation', () => {
const predicate = queryToPredicate(parseSearchQuery('-deprecated')); const predicate = queryToPredicate(parseSearchQuery('-deprecated'));
expect(predicate(createContext())).toBeTrue(); expect(predicate(createContext())).toBe(true);
expect(predicate(createContext({ content: 'deprecated feature' }))).toBeFalse(); expect(predicate(createContext({ content: 'deprecated feature' }))).toBe(false);
}); });
it('queryToPredicate matches task scopes', () => { it('queryToPredicate matches task scopes', () => {
const todoPredicate = queryToPredicate(parseSearchQuery('task-todo:Call')); const todoPredicate = queryToPredicate(parseSearchQuery('task-todo:Call'));
const donePredicate = queryToPredicate(parseSearchQuery('task-done:Review')); const donePredicate = queryToPredicate(parseSearchQuery('task-done:Review'));
expect(todoPredicate(createContext())).toBeTrue(); expect(todoPredicate(createContext())).toBe(true);
expect(donePredicate(createContext())).toBeTrue(); expect(donePredicate(createContext())).toBe(true);
}); });
it('detectQueryType recognises path prefix', () => { it('detectQueryType recognises path prefix', () => {

View File

@ -10,9 +10,9 @@ describe('MarkdownService', () => {
it('renders tables with inline markdown content', () => { it('renders tables with inline markdown content', () => {
const html = render(`| Syntax | Description |\n| --- | --- |\n| **bold** | \`code\` |\n`); const html = render(`| Syntax | Description |\n| --- | --- |\n| **bold** | \`code\` |\n`);
expect(html.includes('<table')).toBeTrue(); expect(html.includes('<table')).toBe(true);
expect(html.includes('<strong>bold</strong>')).toBeTrue(); expect(html.includes('<strong>bold</strong>')).toBe(true);
expect(html.includes('<code class="inline-code">code</code>')).toBeTrue(); expect(html.includes('<code class="inline-code">code</code>')).toBe(true);
}); });
it('applies alignment markers for columns', () => { 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 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 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); const hasRight = /text-align:\s*right\b/.test(html) || /align=\"right\"/.test(html);
expect(hasLeft).toBeTrue(); expect(hasLeft).toBe(true);
expect(hasCenter).toBeTrue(); expect(hasCenter).toBe(true);
expect(hasRight).toBeTrue(); expect(hasRight).toBe(true);
}); });
it('falls back gracefully when separator row is malformed', () => { it('falls back gracefully when separator row is malformed', () => {
const html = render(`| A | B |\n| -- | |\n| 1 | 2 |\n`); const html = render(`| A | B |\n| -- | |\n| 1 | 2 |\n`);
expect(html.includes('<div class="markdown-table"><table>')).toBeFalse(); expect(html.includes('<div class="markdown-table"><table>')).toBe(false);
expect(html.includes('| A | B |')).toBeTrue(); expect(html.includes('| A | B |')).toBe(true);
}); });
}); });

View File

@ -1,18 +1,26 @@
{ {
"collapse-filter": false, "collapse-filter": true,
"search": "", "search": "",
"showTags": false, "showTags": false,
"showAttachments": false, "showAttachments": false,
"hideUnresolved": true, "hideUnresolved": false,
"showOrphans": true, "showOrphans": false,
"collapse-color-groups": false, "collapse-color-groups": true,
"colorGroups": [], "colorGroups": [
"collapse-display": false, {
"query": "tag:test",
"color": {
"a": 1,
"rgb": 11657324
}
}
],
"collapse-display": true,
"showArrow": false, "showArrow": false,
"textFadeMultiplier": 0, "textFadeMultiplier": 0,
"nodeSizeMultiplier": 1, "nodeSizeMultiplier": 1,
"lineSizeMultiplier": 1, "lineSizeMultiplier": 1,
"collapse-forces": false, "collapse-forces": true,
"centerStrength": 0.5, "centerStrength": 0.5,
"repelStrength": 10, "repelStrength": 10,
"linkStrength": 1, "linkStrength": 1,

View File

@ -3,7 +3,7 @@
"search": "", "search": "",
"showTags": false, "showTags": false,
"showAttachments": false, "showAttachments": false,
"hideUnresolved": false, "hideUnresolved": true,
"showOrphans": true, "showOrphans": true,
"collapse-color-groups": false, "collapse-color-groups": false,
"colorGroups": [], "colorGroups": [],