refactor: replace toBeTrue/toBeFalse with toBe(true/false) in test assertions
This commit is contained in:
parent
77ced60d7c
commit
a948d10512
@ -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);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
@ -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);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
@ -21,37 +21,37 @@ const createContext = (overrides: Partial<SearchContext> = {}): 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', () => {
|
||||
|
@ -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('<table')).toBeTrue();
|
||||
expect(html.includes('<strong>bold</strong>')).toBeTrue();
|
||||
expect(html.includes('<code class="inline-code">code</code>')).toBeTrue();
|
||||
expect(html.includes('<table')).toBe(true);
|
||||
expect(html.includes('<strong>bold</strong>')).toBe(true);
|
||||
expect(html.includes('<code class="inline-code">code</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('<div class="markdown-table"><table>')).toBeFalse();
|
||||
expect(html.includes('| A | B |')).toBeTrue();
|
||||
expect(html.includes('<div class="markdown-table"><table>')).toBe(false);
|
||||
expect(html.includes('| A | B |')).toBe(true);
|
||||
});
|
||||
});
|
||||
|
22
vault/.obsidian/graph.json
vendored
22
vault/.obsidian/graph.json
vendored
@ -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,
|
||||
|
2
vault/.obsidian/graph.json.bak
vendored
2
vault/.obsidian/graph.json.bak
vendored
@ -3,7 +3,7 @@
|
||||
"search": "",
|
||||
"showTags": false,
|
||||
"showAttachments": false,
|
||||
"hideUnresolved": false,
|
||||
"hideUnresolved": true,
|
||||
"showOrphans": true,
|
||||
"collapse-color-groups": false,
|
||||
"colorGroups": [],
|
||||
|
Loading…
x
Reference in New Issue
Block a user