"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const vitest_1 = require("vitest");
const git_url_js_1 = require("./git-url.js");
(0, vitest_1.describe)('isValidGitUrl', () => {
    vitest_1.it.each([
        'https://github.com/org/repo.git',
        'https://github.com/org/repo',
        'http://gitlab.com/org/repo.git',
        'git@github.com:org/repo.git',
        'git@gitlab.com:org/repo'
    ])('returns true for %s', (url) => {
        (0, vitest_1.expect)((0, git_url_js_1.isValidGitUrl)(url)).toBe(true);
    });
    vitest_1.it.each(['', 'not-a-url', 'ftp://github.com/org/repo', 'https://'])('returns false for %j', (url) => {
        (0, vitest_1.expect)((0, git_url_js_1.isValidGitUrl)(url)).toBe(false);
    });
    (0, vitest_1.it)('trims whitespace', () => {
        (0, vitest_1.expect)((0, git_url_js_1.isValidGitUrl)('  https://github.com/org/repo  ')).toBe(true);
    });
});
(0, vitest_1.describe)('isGitHubUrl', () => {
    vitest_1.it.each(['https://github.com/org/repo.git', 'https://github.com/org/repo', 'git@github.com:org/repo.git'])('returns true for %s', (url) => {
        (0, vitest_1.expect)((0, git_url_js_1.isGitHubUrl)(url)).toBe(true);
    });
    vitest_1.it.each(['https://gitlab.com/org/repo', 'git@bitbucket.org:org/repo.git', 'https://example.com/org/repo', 'not-a-url'])('returns false for %s', (url) => {
        (0, vitest_1.expect)((0, git_url_js_1.isGitHubUrl)(url)).toBe(false);
    });
    (0, vitest_1.it)('is case-insensitive on the host', () => {
        (0, vitest_1.expect)((0, git_url_js_1.isGitHubUrl)('https://GitHub.COM/org/repo')).toBe(true);
    });
});
(0, vitest_1.describe)('gitRemoteUrlToWeb', () => {
    vitest_1.it.each([
        ['https://github.com/org/repo.git', 'https://github.com/org/repo'],
        ['https://github.com/org/repo', 'https://github.com/org/repo'],
        ['http://gitlab.com/org/repo.git', 'http://gitlab.com/org/repo'],
        ['git@github.com:org/repo.git', 'https://github.com/org/repo'],
        ['git@gitlab.com:group/sub/repo.git', 'https://gitlab.com/group/sub/repo'],
        // Azure DevOps HTTPS with userinfo (clone URL default format)
        ['https://myorg@dev.azure.com/myorg/myproject/_git/myrepo', 'https://dev.azure.com/myorg/myproject/_git/myrepo'],
        // Azure DevOps SSH formats
        ['git@ssh.dev.azure.com:v3/myorg/myproject/myrepo', 'https://dev.azure.com/myorg/myproject/_git/myrepo'],
        ['ssh://git@ssh.dev.azure.com/v3/myorg/myproject/myrepo', 'https://dev.azure.com/myorg/myproject/_git/myrepo']
    ])('converts %s → %s', (input, expected) => {
        (0, vitest_1.expect)((0, git_url_js_1.gitRemoteUrlToWeb)(input)).toBe(expected);
    });
    (0, vitest_1.it)('strips userinfo from HTTPS URLs', () => {
        (0, vitest_1.expect)((0, git_url_js_1.gitRemoteUrlToWeb)('https://myorg@dev.azure.com/myorg/myproject/_git/myrepo')).toBe('https://dev.azure.com/myorg/myproject/_git/myrepo');
    });
    (0, vitest_1.it)('returns null for unconvertible URLs', () => {
        (0, vitest_1.expect)((0, git_url_js_1.gitRemoteUrlToWeb)('not-a-url')).toBeNull();
    });
});
(0, vitest_1.describe)('getGitHubCompareUrl', () => {
    const base = { fromBranch: 'feature/cool', toBranch: 'main' };
    (0, vitest_1.it)('builds a GitHub compare URL', () => {
        (0, vitest_1.expect)((0, git_url_js_1.getGitHubCompareUrl)({
            gitRemoteUrl: 'https://github.com/org/repo.git',
            ...base
        })).toBe('https://github.com/org/repo/compare/main...feature%2Fcool');
    });
    (0, vitest_1.it)('appends title and body', () => {
        (0, vitest_1.expect)((0, git_url_js_1.getGitHubCompareUrl)({
            gitRemoteUrl: 'https://github.com/org/repo.git',
            ...base,
            title: 'My PR',
            body: '## Summary'
        })).toBe('https://github.com/org/repo/compare/main...feature%2Fcool?expand=1&title=My+PR&body=%23%23+Summary');
    });
    (0, vitest_1.it)('returns null for non-GitHub URLs', () => {
        (0, vitest_1.expect)((0, git_url_js_1.getGitHubCompareUrl)({
            gitRemoteUrl: 'https://gitlab.com/org/repo',
            ...base
        })).toBeNull();
    });
    (0, vitest_1.it)('returns null for unconvertible URLs', () => {
        (0, vitest_1.expect)((0, git_url_js_1.getGitHubCompareUrl)({ gitRemoteUrl: 'not-a-url', ...base })).toBeNull();
    });
});
(0, vitest_1.describe)('GITHUB_PAT_SETTINGS_URL', () => {
    (0, vitest_1.it)('is a valid URL', () => {
        (0, vitest_1.expect)(git_url_js_1.GITHUB_PAT_SETTINGS_URL).toBe('https://github.com/settings/tokens');
    });
});
//# sourceMappingURL=git-url.test.js.map