2018-07-06 08:38:09 +00:00
|
|
|
/*globals describe, it*/
|
|
|
|
const assert = require('assert');
|
2018-08-08 16:37:22 +00:00
|
|
|
const TemplateGenerator = require('../lib/utils/template_generator');
|
2018-07-06 08:38:09 +00:00
|
|
|
|
|
|
|
describe('TemplateGenerator', function () {
|
|
|
|
describe('getExternalProject', function () {
|
|
|
|
let templateGenerator;
|
|
|
|
|
|
|
|
before(() => {
|
|
|
|
templateGenerator = new TemplateGenerator();
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('with github link', function () {
|
|
|
|
|
2018-07-06 15:02:25 +00:00
|
|
|
it('return correct zip filename for https link', function () {
|
2018-07-06 08:38:09 +00:00
|
|
|
let result = templateGenerator.getExternalProject("https://github.com/embark-framework/embark");
|
2018-07-06 15:02:25 +00:00
|
|
|
assert.strictEqual(result.url, "https://github.com/embark-framework/embark/archive/master.zip");
|
2018-09-05 21:59:42 +00:00
|
|
|
assert.strictEqual(result.filePath.replace(/\\/g,'/'), ".embark/templates/embark-framework/embark/master/archive.zip");
|
|
|
|
});
|
|
|
|
|
|
|
|
it('return correct zip filename for https link with branch specified', function () {
|
|
|
|
let result = templateGenerator.getExternalProject("https://github.com/embark-framework/embark/tree/develop");
|
|
|
|
assert.strictEqual(result.url, "https://github.com/embark-framework/embark/archive/develop.zip");
|
|
|
|
assert.strictEqual(result.filePath.replace(/\\/g,'/'), ".embark/templates/embark-framework/embark/develop/archive.zip");
|
2018-07-06 08:38:09 +00:00
|
|
|
});
|
|
|
|
|
2018-07-06 15:02:25 +00:00
|
|
|
it('return correct zip filename for http link', function () {
|
2018-07-06 08:38:09 +00:00
|
|
|
let result = templateGenerator.getExternalProject("http://github.com/embark-framework/embark");
|
2018-09-05 21:59:42 +00:00
|
|
|
assert.strictEqual(result.url, "https://github.com/embark-framework/embark/archive/master.zip");
|
|
|
|
assert.strictEqual(result.filePath.replace(/\\/g,'/'), ".embark/templates/embark-framework/embark/master/archive.zip");
|
2018-07-06 08:38:09 +00:00
|
|
|
});
|
|
|
|
|
2018-09-05 21:59:42 +00:00
|
|
|
it('return correct zip filename for http link with branch specified', function () {
|
|
|
|
let result = templateGenerator.getExternalProject("http://github.com/embark-framework/embark/tree/develop");
|
|
|
|
assert.strictEqual(result.url, "https://github.com/embark-framework/embark/archive/develop.zip");
|
|
|
|
assert.strictEqual(result.filePath.replace(/\\/g,'/'), ".embark/templates/embark-framework/embark/develop/archive.zip");
|
2018-07-06 08:38:09 +00:00
|
|
|
});
|
|
|
|
|
2018-07-06 15:02:25 +00:00
|
|
|
it('return correct zip filename without protocol specified ', function () {
|
2018-07-06 08:38:09 +00:00
|
|
|
let result = templateGenerator.getExternalProject("github.com/embark-framework/embark");
|
2018-07-06 15:02:25 +00:00
|
|
|
assert.strictEqual(result.url, "https://github.com/embark-framework/embark/archive/master.zip");
|
2018-09-05 21:59:42 +00:00
|
|
|
assert.strictEqual(result.filePath.replace(/\\/g,'/'), ".embark/templates/embark-framework/embark/master/archive.zip");
|
|
|
|
});
|
|
|
|
|
|
|
|
it('return correct zip filename without protocol with branch specified', function () {
|
|
|
|
let result = templateGenerator.getExternalProject("github.com/embark-framework/embark#develop");
|
|
|
|
assert.strictEqual(result.url, "https://github.com/embark-framework/embark/archive/develop.zip");
|
|
|
|
assert.strictEqual(result.filePath.replace(/\\/g,'/'), ".embark/templates/embark-framework/embark/develop/archive.zip");
|
2018-07-06 08:38:09 +00:00
|
|
|
});
|
|
|
|
|
2018-07-06 15:02:25 +00:00
|
|
|
it('return correct zip filename with just username/repo specified', function () {
|
2018-07-06 08:38:09 +00:00
|
|
|
let result = templateGenerator.getExternalProject("embark-framework/embark");
|
2018-07-06 15:02:25 +00:00
|
|
|
assert.strictEqual(result.url, "https://github.com/embark-framework/embark/archive/master.zip");
|
2018-09-05 21:59:42 +00:00
|
|
|
assert.strictEqual(result.filePath.replace(/\\/g,'/'), ".embark/templates/embark-framework/embark/master/archive.zip");
|
|
|
|
});
|
|
|
|
|
|
|
|
it('return correct zip filename with just username/repo and branch specified', function () {
|
|
|
|
let result = templateGenerator.getExternalProject("embark-framework/embark#develop");
|
|
|
|
assert.strictEqual(result.url, "https://github.com/embark-framework/embark/archive/develop.zip");
|
|
|
|
assert.strictEqual(result.filePath.replace(/\\/g,'/'), ".embark/templates/embark-framework/embark/develop/archive.zip");
|
2018-07-06 08:38:09 +00:00
|
|
|
});
|
|
|
|
|
2018-07-06 15:02:25 +00:00
|
|
|
it('return correct zip filename with just embark template specified', function () {
|
2018-07-06 08:38:09 +00:00
|
|
|
let result = templateGenerator.getExternalProject("react");
|
2018-07-06 15:02:25 +00:00
|
|
|
assert.strictEqual(result.url, "https://github.com/embark-framework/embark-react-template/archive/master.zip");
|
2018-07-09 17:24:07 +00:00
|
|
|
assert.strictEqual(result.filePath.replace(/\\/g,'/'), ".embark/templates/embark-framework/embark-react-template/archive.zip");
|
2018-07-06 08:38:09 +00:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|