<commit_before>import * as chai from 'chai'
const expect = chai.expect

import { groupRepositories } from '../../src/ui/clone-repository/group-repositories'
import { IAPIRepository, IAPIUser } from '../../src/lib/api'

const users = {
  shiftkey: {
    id: 1,
    url: '',
    login: 'shiftkey',
    avatar_url: '',
    name: '<NAME>',
    type: 'User',
  } as IAPIUser,
  desktop: {
    id: 2,
    url: '',
    login: 'desktop',
    avatar_url: '',
    name: 'Desktop',
    type: 'Organization',
  } as IAPIUser,
  octokit: {
    id: 3,
    url: '',
    login: 'octokit',
    avatar_url: '',
    name: 'Octokit',
    type: 'Organization',
  } as IAPIUser,
}

describe('clone repository grouping', () => {
  it('groups repositories by organization', () => {
    const repositories: Array<IAPIRepository> = [
      {
        clone_url: '',
        html_url: '',
        name: 'some-repo',
        owner: users.shiftkey,
        private: true,
        fork: true,
        default_branch: '',
      },
      {
        clone_url: '',
        html_url: '',
        name: 'octokit.net',
        owner: users.octokit,
        private: false,
        fork: false,
        default_branch: '',
      },
      {
        clone_url: '',
        html_url: '',
        name: 'desktop',
        owner: users.desktop,
        private: true,
        fork: false,
        default_branch: '',
      },
    ]

    const grouped = groupRepositories(repositories, 'shiftkey')
    expect(grouped.length).to.equal(3)

    expect(grouped[0].identifier).to.equal('user repos')
    expect(grouped[0].items.length).to.equal(1)

    let item = grouped[0].items[0]
    expect(item.name).to.equal('some-repo')

    expect(grouped[1].identifier).to.equal('desktop')
    expect(grouped[1].items.length).to.equal(1)

    item = grouped[1].items[0]
    expect(item.name).to.equal('desktop')

    item = grouped[2].items[0]
    expect(grouped[2].identifier).to.equal('octokit')
    expect(grouped[2].items.length).to.equal(1)

    item = grouped[2].items[0]
    expect(item.name).to.equal('octokit.net')
  })
})<commit_msg>s/user repos/your repositories<commit_after>import * as chai from 'chai'
const expect = chai.expect

import { groupRepositories } from '../../src/ui/clone-repository/group-repositories'
import { IAPIRepository, IAPIUser } from '../../src/lib/api'

const users = {
  shiftkey: {
    id: 1,
    url: '',
    login: 'shiftkey',
    avatar_url: '',
    name: '<NAME>',
    type: 'User',
  } as IAPIUser,
  desktop: {
    id: 2,
    url: '',
    login: 'desktop',
    avatar_url: '',
    name: 'Desktop',
    type: 'Organization',
  } as IAPIUser,
  octokit: {
    id: 3,
    url: '',
    login: 'octokit',
    avatar_url: '',
    name: 'Octokit',
    type: 'Organization',
  } as IAPIUser,
}

describe('clone repository grouping', () => {
  it('groups repositories by organization', () => {
    const repositories: Array<IAPIRepository> = [
      {
        clone_url: '',
        html_url: '',
        name: 'some-repo',
        owner: users.shiftkey,
        private: true,
        fork: true,
        default_branch: '',
      },
      {
        clone_url: '',
        html_url: '',
        name: 'octokit.net',
        owner: users.octokit,
        private: false,
        fork: false,
        default_branch: '',
      },
      {
        clone_url: '',
        html_url: '',
        name: 'desktop',
        owner: users.desktop,
        private: true,
        fork: false,
        default_branch: '',
      },
    ]

    const grouped = groupRepositories(repositories, 'shiftkey')
    expect(grouped.length).to.equal(3)

    expect(grouped[0].identifier).to.equal('Your repositories')
    expect(grouped[0].items.length).to.equal(1)

    let item = grouped[0].items[0]
    expect(item.name).to.equal('some-repo')

    expect(grouped[1].identifier).to.equal('desktop')
    expect(grouped[1].items.length).to.equal(1)

    item = grouped[1].items[0]
    expect(item.name).to.equal('desktop')

    item = grouped[2].items[0]
    expect(grouped[2].identifier).to.equal('octokit')
    expect(grouped[2].items.length).to.equal(1)

    item = grouped[2].items[0]
    expect(item.name).to.equal('octokit.net')
  })
})
{'fraction_non_alphanumeric': 0.1701620591039085, 'fraction_numerical': 0.010009532888465206, 'mean_word_length': 2.4261224489795916, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5824427', 'n_tokens_mistral': 1481, 'n_tokens_neox': 1422, 'n_words': 252}