// ========= Copyright 2026 @ Strukto.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 2026 @ Strukto.AI All Rights Reserved. =========

import { describe, expect, it } from 'vitest'
import { DiskIndexEntry, DiskResourceType } from './entry.ts'

describe('DiskResourceType', () => {
  it('has FILE and FOLDER constants', () => {
    expect(DiskResourceType.FILE).toBe('file')
    expect(DiskResourceType.FOLDER).toBe('folder')
  })
})

describe('DiskIndexEntry.file', () => {
  it('builds a file entry from a virtual path', () => {
    const e = DiskIndexEntry.file('/a/b.txt', 42, '2026-01-01')
    expect(e.id).toBe('/a/b.txt')
    expect(e.name).toBe('b.txt')
    expect(e.vfsName).toBe('b.txt')
    expect(e.size).toBe(42)
    expect(e.resourceType).toBe(DiskResourceType.FILE)
  })

  it('defaults size to 0 and modified to empty string', () => {
    const e = DiskIndexEntry.file('/x.txt')
    expect(e.size).toBe(0)
  })
})

describe('DiskIndexEntry.folder', () => {
  it('builds a folder entry', () => {
    const e = DiskIndexEntry.folder('/dir', '2026-01-01')
    expect(e.name).toBe('dir')
    expect(e.resourceType).toBe(DiskResourceType.FOLDER)
  })
})
