mirror of
https://github.com/colanode/colanode.git
synced 2026-07-10 20:40:09 +02:00
Fix lint errors (import ordering), resolve FileReadStream type mismatch for mobile's Blob-based readStream, move tests from src/__tests__ to top-level test/ directory matching web/server conventions, and add tests for emoji, message, node, radar utils plus an in-memory error log for debugging experimental builds. Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
58 lines
1.8 KiB
TypeScript
58 lines
1.8 KiB
TypeScript
import { LocalNode } from '@colanode/client/types/nodes';
|
|
import {
|
|
NODE_TYPE_LABELS,
|
|
getNodeDisplayName,
|
|
} from '@colanode/mobile/lib/node-utils';
|
|
|
|
const makeNode = (overrides: Partial<LocalNode> & { type: string; name: string }) => {
|
|
return {
|
|
id: 'testid',
|
|
rootId: 'root1',
|
|
parentId: null,
|
|
createdAt: '2024-01-01T00:00:00Z',
|
|
createdBy: 'user1',
|
|
updatedAt: null,
|
|
updatedBy: null,
|
|
localRevision: '1',
|
|
serverRevision: '1',
|
|
...overrides,
|
|
} as LocalNode;
|
|
};
|
|
|
|
describe('NODE_TYPE_LABELS', () => {
|
|
it('should have labels for common node types', () => {
|
|
expect(NODE_TYPE_LABELS['channel']).toBe('Channel');
|
|
expect(NODE_TYPE_LABELS['page']).toBe('Page');
|
|
expect(NODE_TYPE_LABELS['folder']).toBe('Folder');
|
|
expect(NODE_TYPE_LABELS['database']).toBe('Database');
|
|
expect(NODE_TYPE_LABELS['file']).toBe('File');
|
|
});
|
|
|
|
it('should return undefined for unknown types', () => {
|
|
expect(NODE_TYPE_LABELS['unknown']).toBeUndefined();
|
|
});
|
|
});
|
|
|
|
describe('getNodeDisplayName', () => {
|
|
it('should return "Chat" for chat nodes', () => {
|
|
const node = makeNode({ type: 'chat', name: 'some-name' });
|
|
expect(getNodeDisplayName(node)).toBe('Chat');
|
|
});
|
|
|
|
it('should return node name or "Message" for message nodes', () => {
|
|
const namedMsg = makeNode({ type: 'message', name: 'Re: topic' });
|
|
expect(getNodeDisplayName(namedMsg)).toBe('Re: topic');
|
|
|
|
const unnamedMsg = makeNode({ type: 'message', name: undefined as unknown as string });
|
|
expect(getNodeDisplayName(unnamedMsg)).toBe('Message');
|
|
});
|
|
|
|
it('should return node name for other types', () => {
|
|
const page = makeNode({ type: 'page', name: 'My Page' });
|
|
expect(getNodeDisplayName(page)).toBe('My Page');
|
|
|
|
const channel = makeNode({ type: 'channel', name: 'General' });
|
|
expect(getNodeDisplayName(channel)).toBe('General');
|
|
});
|
|
});
|