@platform/react.ssr
Version:
A lightweight SSR (server-side-rendering) system for react apps bundled with ParcelJS and hosted on S3.
80 lines (79 loc) • 3.26 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
var tslib_1 = require("tslib");
var _1 = require(".");
var test_1 = require("../test");
var baseUrl = 'https://sfo2.digitaloceanspaces.com/platform/modules/react.ssr';
var testSite = function () { return tslib_1.__awaiter(void 0, void 0, void 0, function () {
var manifest, site;
return tslib_1.__generator(this, function (_a) {
switch (_a.label) {
case 0: return [4, test_1.testManifest()];
case 1:
manifest = _a.sent();
return [4, manifest.site.byHost('localhost')];
case 2:
site = _a.sent();
return [2, site];
}
});
}); };
describe('Site', function () {
it('props (default)', function () { return tslib_1.__awaiter(void 0, void 0, void 0, function () {
var site;
return tslib_1.__generator(this, function (_a) {
switch (_a.label) {
case 0: return [4, testSite()];
case 1:
site = _a.sent();
test_1.expect(site.domain).to.include('localhost');
test_1.expect(site.version).to.eql('1.2.3-alpha.0');
test_1.expect(site.files).to.eql([]);
test_1.expect(site.name).to.eql('dev');
test_1.expect(site.bundle).to.eql('path/bundle/1.2.3-alpha.0');
return [2];
}
});
}); });
it('throws when no name', function () { return tslib_1.__awaiter(void 0, void 0, void 0, function () {
var def, manifest, fn;
return tslib_1.__generator(this, function (_a) {
switch (_a.label) {
case 0: return [4, test_1.testManifestDef()];
case 1:
def = _a.sent();
delete def.sites[0].name;
manifest = _1.Manifest.create({ def: def, baseUrl: baseUrl });
fn = function () { return manifest.site.byHost('localhost'); };
test_1.expect(fn).to.throw(/must have a name/);
return [2];
}
});
}); });
it('routes', function () { return tslib_1.__awaiter(void 0, void 0, void 0, function () {
var site, res;
return tslib_1.__generator(this, function (_a) {
switch (_a.label) {
case 0: return [4, testSite()];
case 1:
site = _a.sent();
res = site.routes;
test_1.expect(res.length).to.greaterThan(0);
return [2];
}
});
}); });
it('version from bundle path', function () { return tslib_1.__awaiter(void 0, void 0, void 0, function () {
var manifest, site;
return tslib_1.__generator(this, function (_a) {
switch (_a.label) {
case 0: return [4, test_1.testManifest()];
case 1:
manifest = _a.sent();
site = manifest.site.byHost('localhost');
test_1.expect(site && site.version).to.eql('1.2.3-alpha.0');
return [2];
}
});
}); });
});