{"size": 949, "ext": "js", "max_stars_repo_path": "src/github.test.js", "max_stars_repo_name": "dragonraid/deployment-bumper", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "src/github.test.js", "max_issues_repo_name": "dragonraid/deployment-bumper", "max_issues_repo_issues_event_min_datetime": "2020-12-12T09:29:26.000Z", "max_issues_repo_issues_event_max_datetime": "2021-01-09T14:46:35.000Z", "max_forks_repo_path": "src/github.test.js", "max_forks_repo_name": "dragonraid/deployment-bumper", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": 3, "max_forks_count": null, "avg_line_length": 31.6333333333, "max_line_length": 90, "alphanum_fraction": 0.5732349842}
const { Repository } = require('./github');

const username = 'username';
const password = 'password';
const repository = 'foo/bar';

describe('Repository', () => {
    test('can be initialized with credentials', () => {
        const repo = new Repository({ repository, username, password });
        expect(repo.url).toBe(`https://${username}:${password}@github.com/${repository}`);
    });

    test('can be initialized without credentials', () => {
        const repo = new Repository({ repository });
        expect(repo.url).toBe(`https://github.com/${repository}`);
    });

    test('throws an error, when either username is not supplied', () => {
        expect(() => {
            new Repository({ repository, password });
        }).toThrow();
    });

    test('throws an error, when either password is not supplied', () => {
        expect(() => {
            new Repository({ repository, username });
        }).toThrow();
    });
});
