All files / ua run.js

100% Statements 20/20
85.71% Branches 6/7
100% Functions 5/5
100% Lines 19/19

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31  53x 106x   53x 53x 53x 53x 53x 55x 97x 97x 97x 97x 4353x     97x 97x 97x 97x       96x         53x  
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const encode_1 = require("./encode");
const decode_1 = __importDefault(require("./decode"));
const factory_1 = __importDefault(require("./factory"));
const run = (cases) => {
    for (const c of cases) {
        describe(c.name, () => {
            test('encode', () => {
                const result = new Uint8Array(encode_1.encode({ instance: c.instance }));
                for (let index = 0; index < c.bytes.byteLength; index++) {
                    expect(result[index]).toBe(c.bytes[index]);
                }
            });
            test('decode', () => {
                const name = c.instance.constructor.name;
                const instance = factory_1.default(name);
                decode_1.default({
                    bytes: c.bytes.buffer,
                    instance
                });
                expect(instance).toEqual(c.instance);
            });
        });
    }
};
exports.default = run;