embark/test/template.js

56 lines
2.8 KiB
JavaScript
Raw Normal View History

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");
assert.strictEqual(result.filePath.replace(/\\/g,'/'), ".embark/templates/embark-framework/embark/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-07-06 15:02:25 +00:00
assert.strictEqual(result.url, "http://github.com/embark-framework/embark/archive/master.zip");
assert.strictEqual(result.filePath.replace(/\\/g,'/'), ".embark/templates/embark-framework/embark/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");
assert.strictEqual(result.filePath.replace(/\\/g,'/'), ".embark/templates/embark-framework/embark/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");
assert.strictEqual(result.filePath.replace(/\\/g,'/'), ".embark/templates/embark-framework/embark/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");
assert.strictEqual(result.filePath.replace(/\\/g,'/'), ".embark/templates/embark-framework/embark/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");
assert.strictEqual(result.filePath.replace(/\\/g,'/'), ".embark/templates/embark-framework/embark-react-template/archive.zip");
2018-07-06 08:38:09 +00:00
});
});
});
});