import * as compareUtils from './compareUtils';
const fileTree = [{
  name: 'upload_test_folder',
  path: 'upload_test_folder',
  type: 'folder',
  timestamp: 1658305970383,
  content: [{
    name: 'file.txt',
    path: 'upload_test_folder/file.txt',
    type: 'file',
    timestamp: 1658305970383,
    content: []
  }, {
    name: 'inner_folder',
    path: 'upload_test_folder/inner_folder',
    type: 'folder',
    timestamp: 1658305970383,
    content: [{
      name: 'file.txt',
      path: 'upload_test_folder/inner_folder/file.txt',
      type: 'file',
      timestamp: 1658305970383,
      content: []
    }, {
      name: 'inner_folder',
      path: 'upload_test_folder/inner_folder/inner_folder',
      type: 'folder',
      timestamp: 1658305970383,
      content: []
    }]
  }, {
    name: 'file copy.txt',
    path: 'upload_test_folder/file copy.txt',
    type: 'file',
    timestamp: 1658305970383,
    content: []
  }, {
    name: 'Dockerfile',
    path: 'upload_test_folder/Dockerfile',
    type: 'file',
    timestamp: 1658305970383,
    content: []
  }]
}];
describe('Compare Utils', function () {
  it('should sort file tree items by file name', function () {
    const sortedTree = compareUtils.compareByName(fileTree);
    expect(sortedTree).toEqual([expect.objectContaining({
      name: 'upload_test_folder',
      content: [expect.objectContaining({
        name: 'Dockerfile'
      }), expect.objectContaining({
        name: 'file copy.txt'
      }), expect.objectContaining({
        name: 'file.txt'
      }), expect.objectContaining({
        name: 'inner_folder',
        content: [expect.objectContaining({
          name: 'file.txt'
        }), expect.objectContaining({
          name: 'inner_folder'
        })]
      })]
    })]);
  });
  it('should sort file tree by type and file name', function () {
    const sortedTree = compareUtils.compareByNameAndType(fileTree);
    expect(sortedTree).toEqual([expect.objectContaining({
      name: 'upload_test_folder',
      content: [expect.objectContaining({
        name: 'inner_folder',
        content: [expect.objectContaining({
          name: 'inner_folder'
        }), expect.objectContaining({
          name: 'file.txt'
        })]
      }), expect.objectContaining({
        name: 'Dockerfile'
      }), expect.objectContaining({
        name: 'file copy.txt'
      }), expect.objectContaining({
        name: 'file.txt'
      })]
    })]);
  });
});