mirror of
https://github.com/eigent-ai/eigent.git
synced 2026-08-26 17:12:03 +00:00
55 lines
1.8 KiB
TypeScript
55 lines
1.8 KiB
TypeScript
// ========= Copyright 2025-2026 @ Eigent.ai All Rights Reserved. =========
|
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
// you may not use this file except in compliance with the License.
|
|
// You may obtain a copy of the License at
|
|
//
|
|
// http://www.apache.org/licenses/LICENSE-2.0
|
|
//
|
|
// Unless required by applicable law or agreed to in writing, software
|
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
// See the License for the specific language governing permissions and
|
|
// limitations under the License.
|
|
// ========= Copyright 2025-2026 @ Eigent.ai All Rights Reserved. =========
|
|
|
|
import { buildWorkspaceFileTree } from '@/lib/workspaceFileTree';
|
|
import { describe, expect, it } from 'vitest';
|
|
|
|
describe('buildWorkspaceFileTree', () => {
|
|
it('builds a sorted hierarchy rooted at the current workspace', () => {
|
|
const files: FileInfo[] = [
|
|
{
|
|
name: 'summary.md',
|
|
path: '/workspace/research/reports/summary.md',
|
|
relativePath: 'research/reports/summary.md',
|
|
type: 'md',
|
|
},
|
|
{
|
|
name: 'README.md',
|
|
path: '/workspace/README.md',
|
|
relativePath: 'README.md',
|
|
type: 'md',
|
|
},
|
|
{
|
|
name: 'data.csv',
|
|
path: '/workspace/research/data.csv',
|
|
relativePath: 'research/data.csv',
|
|
type: 'csv',
|
|
},
|
|
];
|
|
|
|
const tree = buildWorkspaceFileTree(files);
|
|
|
|
expect(tree.map((node) => node.name)).toEqual(['research', 'README.md']);
|
|
expect(tree[0].children.map((node) => node.name)).toEqual([
|
|
'reports',
|
|
'data.csv',
|
|
]);
|
|
expect(tree[0].children[0].children[0]).toMatchObject({
|
|
name: 'summary.md',
|
|
relativePath: 'research/reports/summary.md',
|
|
isFolder: false,
|
|
file: files[0],
|
|
});
|
|
});
|
|
});
|