import Urls from 'bitbucket/internal/bbui/urls/urls';

class MockUrls extends Urls {

    fileChanges(repository, commitRange) { // eslint-disable-line no-unused-vars
        return 'http://example.com/' + repository.slug + '/changes';
    }

    avatarUrl(person, size) {
        // this URL is handled by the Sandbox to return a placeholder avatar for testing
        return '/avatar/' + person.name + '/avatar?size=' + size;
    }

    user(_user) {
        return `http://example.com/users/${_user.slug}`;
    }

    pullRequest(_pullRequest) {
        return 'http://example.com/' + _pullRequest.id;
    }

    inboxPullRequest(_project, _repo, _pullRequest) {
        return 'http://example.com/projects/' + _project.id + '/repos/' + _repo.slug + '/pull-requests/' + _pullRequest.id;
    }

    createPullRequest(repository) {
        return 'http://example.com/' + repository.slug + '/create-pull-request';
    }

    allPullRequests(repository) {
        return 'http://example.com/' + repository.slug + '/all-pull-requests';
    }

    help(key) {
        return 'http://example.com/help/' + key;
    }

    search(terms) {
        // the Sandbox URL so that push state followed by refresh works
        return '/components/search' + (terms ? `?q=${terms}` : '');
    }

    project(project) {
        return 'http://example.com/project/' + project.key;
    }

    repo(repository) {
        return 'http://example.com/project/' + repository.project.key + '/repo/' + repository.slug;
    }

    remote(repository) {
        return `http://example.com/scm/${repository.project.key}/${repository.slug}.${repository.scm_id}`;
    }
}

const mocksUrls = new MockUrls();

export default mocksUrls;
export const fileChanges = mocksUrls.fileChanges;
export const avatarUrl = mocksUrls.avatarUrl;
export const user = mocksUrls.user;
export const pullRequest = mocksUrls.pullRequest;
export const createPullRequest = mocksUrls.createPullRequest;
export const allPullRequests = mocksUrls.allPullRequests;
export const help = mocksUrls.help;
export const search = mocksUrls.search;
export const repo = mocksUrls.repo;
