UNPKG

@platform/cell.schema

Version:

URI and database schemas for the `cell.os`.

46 lines (45 loc) 1.95 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var _1 = require("."); var test_1 = require("../../test"); describe('data.http: Manifest', function () { describe('ManifestSource', function () { it('kind: filepath', function () { var path = '/foo/bar/index.json'; var source = (0, _1.ManifestSource)(" ".concat(path, " ")); (0, test_1.expect)(source.kind).to.eql('filepath'); (0, test_1.expect)(source.domain).to.eql('runtime:electron:bundle'); (0, test_1.expect)(source.dir).to.eql('/foo/bar'); (0, test_1.expect)(source.path).to.eql(path); (0, test_1.expect)(source.toString()).to.eql(path); }); it('kind: url', function () { var path = 'https://domain.com:1234/cell:foo:A1/fs/foo/bar/index.json'; var source = (0, _1.ManifestSource)(" ".concat(path, " ")); (0, test_1.expect)(source.kind).to.eql('url'); (0, test_1.expect)(source.path).to.eql(path); (0, test_1.expect)(source.domain).to.eql('domain.com:1234'); (0, test_1.expect)(source.dir).to.eql('/foo/bar'); (0, test_1.expect)(source.toString()).to.eql(path); }); it('throw (create/validate errors)', function () { var test = function (input) { var fn = function () { return (0, _1.ManifestSource)(input); }; (0, test_1.expect)(fn).to.throw(); }; test(''); test(' '); test(undefined); test(null); test({}); test([]); test(123); test(true); test('/foo/bar'); test('/foo/bar.js'); test('foo/bar/index.json'); test('https://domain.com/ns:abc/fs/foo/index.json'); test('https://domain.com/cell:abc:A1/foo/index.json'); }); }); });