UNPKG

@platform/cell.schema

Version:

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

76 lines (75 loc) 2.92 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var test_1 = require("../test"); var _1 = require("."); describe('Squash', function () { it('Squash.props (cell)', function () { var test = function (props, expected) { var res = _1.Squash.props(props); (0, test_1.expect)(res).to.eql(expected); }; test(); test({}); test({ style: {} }); test({ merge: {} }); test({ style: {}, merge: {} }); test({ style: { bold: true }, merge: {} }, { style: { bold: true } }); }); it('Squash.props (row)', function () { var test = function (props, expected) { var res = _1.Squash.props(props); (0, test_1.expect)(res).to.eql(expected); }; test(); test({}); test({ grid: undefined }); test({ grid: {} }); test({ grid: { height: 0 } }, { grid: { height: 0 } }); test({ grid: { height: 123 } }, { grid: { height: 123 } }); test({ foo: null }, { foo: null }); }); it('Squash.props (column)', function () { var test = function (props, expected) { var res = _1.Squash.props(props); (0, test_1.expect)(res).to.eql(expected); }; test(); test({}); test({ grid: undefined }); test({ grid: {} }); test({ grid: { width: 0 } }, { grid: { width: 0 } }); test({ grid: { width: 123 } }, { grid: { width: 123 } }); test({ foo: null }, { foo: null }); }); it('squash.cell', function () { var test = function (cell, expected, empty) { var res = _1.Squash.cell(cell, { empty: empty }); (0, test_1.expect)(res).to.eql(expected); }; test(); test({}); test({ value: undefined }); test({ value: 123 }, { value: 123 }); test({ value: 123, links: {} }, { value: 123 }); test({ value: 0, links: {} }, { value: 0 }); test({ hash: 'sha256...' }); test({ value: 123, hash: 'sha256...' }, { value: 123, hash: 'sha256...' }); test({ value: undefined, error: { type: 'UNKNOWN', message: 'Fail' } }, { error: { type: 'UNKNOWN', message: 'Fail' } }); test({ value: undefined }, {}, {}); test({ value: null }, { value: null }); }); it('squash.object', function () { var test = function (obj, expected, options) { var res = _1.Squash.object(obj, options); (0, test_1.expect)(res).to.eql(expected); }; test(); test({}); test({ hash: 'sha256...' }); test({ foo: undefined, hash: 'sha256...' }); test({ foo: 123, hash: 'sha256...' }, { foo: 123, hash: 'sha256...' }); test({ foo: undefined }); test({ foo: null }, { foo: null }); test({ foo: { value: null } }, { foo: { value: null } }); }); });