refactor: replace toBeTrue/toBeFalse with toBe(true/false) in test assertions
This commit is contained in:
@@ -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);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user