import { tap, expect } from '@git.zone/tstest/tapbundle';
import * as tsview from '../ts/index.js';

tap.test('should export TsView class', async () => {
  expect(tsview.TsView).toBeDefined();
});

tap.test('should create TsView instance', async () => {
  const viewer = new tsview.TsView();
  expect(viewer).toBeInstanceOf(tsview.TsView);
  expect(viewer.config).toBeDefined();
});

tap.test('should have config methods', async () => {
  const viewer = new tsview.TsView();

  // Set storage config
  viewer.setStorageConfig({
    endpoint: 'localhost',
    port: 9000,
    accessKey: 'test',
    accessSecret: 'test',
    useSsl: false,
  });

  expect(viewer.config.hasStorage()).toBeTrue();
  expect(viewer.config.hasMongo()).toBeFalse();

  // Set MongoDB config
  viewer.setMongoConfig({
    mongoDbUrl: 'mongodb://localhost:27017',
    mongoDbName: 'test',
  });

  expect(viewer.config.hasMongo()).toBeTrue();
});

tap.test('should have runCli export', async () => {
  expect(tsview.runCli).toBeDefined();
  expect(typeof tsview.runCli).toEqual('function');
});

export default tap.start();
