All files / json-pack/src/__tests__ msgpack-documents.ts

100% Statements 3/3
100% Branches 0/0
100% Functions 0/0
100% Lines 3/3

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 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 621x 1x               1x                                                                                                        
import {JsonPackExtension, JsonPackValue} from '../msgpack';
import {encodeFull} from '../msgpack/util';
 
export interface JsonDocument {
  name: string;
  json: unknown;
  only?: true;
}
 
export const msgPackDocuments: JsonDocument[] = [
  {
    name: 'MessagePack value {foo: "bar"}',
    json: new JsonPackValue(encodeFull({foo: 'bar'})),
  },
  {
    name: 'MessagePack value null',
    json: new JsonPackValue(encodeFull(null)),
  },
  {
    name: 'MessagePack value in object',
    json: {
      foo: new JsonPackValue(encodeFull(null)),
    },
  },
  {
    name: 'MessagePack value in array',
    json: [new JsonPackValue(encodeFull(null))],
  },
  {
    name: 'MessagePack extension',
    json: new JsonPackExtension(1, new Uint8Array([1, 2, 3])),
  },
  {
    name: 'MessagePack extension in object',
    json: {
      foo: new JsonPackExtension(1, new Uint8Array([1, 2, 3])),
    },
  },
  {
    name: 'MessagePack extension in array',
    json: [new JsonPackExtension(1, new Uint8Array([1, 2, 3]))],
  },
  {
    name: 'MessasgePack complex document with extensions and values',
    json: {
      foo: new JsonPackValue(encodeFull(null)),
      bar: new JsonPackExtension(1, new Uint8Array([1, 2, 3])),
      baz: new JsonPackExtension(1, new Uint8Array([1, 2, 3])),
      arr: [
        new JsonPackValue(encodeFull(null)),
        new JsonPackExtension(1, new Uint8Array([1, 2, 3])),
        new Uint8Array([1, 2, 3, 7]),
      ],
      f: false,
      n: null,
      t: true,
      _n: 123,
      s: 'sssss',
    },
  },
];