gitly
Version:
An API to download and/or extract git repositories
39 lines (38 loc) • 2.11 kB
JavaScript
;
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const parse_1 = __importDefault(require("../parse"));
const archive_1 = require("../archive");
const archive_2 = require("../archive");
const isWin32 = process.platform === 'win32';
describe('utils/archive', () => {
describe('getUrl()', () => {
it('should return a github url to the zipped file', () => {
expect((0, archive_1.getArchiveUrl)((0, parse_1.default)('iwatakeshi/test'))).toEqual('https://github.com/iwatakeshi/test/archive/master.tar.gz');
});
it('should return a bitbucket url to the zipped file', () => {
expect((0, archive_1.getArchiveUrl)((0, parse_1.default)('bitbucket:iwatakeshi/test'))).toEqual('https://bitbucket.org/iwatakeshi/test/get/master.tar.gz');
});
it('should return a gitlab url to the zipped file', () => {
expect((0, archive_1.getArchiveUrl)((0, parse_1.default)('gitlab:iwatakeshi/test'))).toEqual('https://gitlab.com/iwatakeshi/test/-/archive/master/test-master.tar.gz');
});
it('should return a custom url to the zipped file', () => {
expect((0, archive_1.getArchiveUrl)((0, parse_1.default)('iwatakeshi/test'), {
url: {
filter(info) {
return `https://domain.com${info.path}/repo/archive.tar.gz?ref=${info.type}`;
},
},
})).toEqual('https://domain.com/iwatakeshi/test/repo/archive.tar.gz?ref=master');
});
});
describe('getArchivePath()', () => {
it('should return a path to the zipped file', () => {
expect((0, archive_2.getArchivePath)((0, parse_1.default)('iwatakeshi/test'))).toEqual(isWin32
? expect.stringMatching(/\.gitly\\github\\iwatakeshi\\test\\master\.tar\.gz/)
: expect.stringMatching(/\.gitly\/github\/iwatakeshi\/test\/master\.tar\.gz/));
});
});
});