UNPKG

@platform/cell.schema

Version:

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

37 lines (36 loc) 1.23 kB
import { expect } from '../test'; import { FileSchema, FileLinks } from '.'; import { Schema } from '../Schema'; describe('FileSchema', () => { it('exposed from Schema (static)', () => { expect(Schema.file).to.equal(FileSchema); expect(Schema.file.links).to.equal(FileLinks); }); it('uri', () => { const path = 'NS/foo/FILE/filename'; expect(FileSchema.uri({ path })).to.eql('file:foo:filename'); }); it('uri (throws)', () => { const test = (path) => { const fn = () => FileSchema.uri({ path }); expect(fn).to.throw(); }; test('/foo/filename'); test('NS/foo/filename'); test('BOO/foo/FILE/filename'); }); it('toFileLocation', () => { const test = (input, expected) => { const res = FileSchema.toFileLocation(input); expect(res).to.eql(expected); }; test(undefined, 'file://'); test('', 'file://'); test(' ', 'file://'); test('/foo', 'file:///foo'); test(' /foo ', 'file:///foo'); test('http://foo', 'http://foo'); test('https://foo', 'https://foo'); test(' https://foo ', 'https://foo'); }); });