UNPKG

1.63 kBJavaScriptView Raw
1#!/usr/bin/env mocha -R spec
2
3var assert = require("assert");
4
5var msgpack = require("../index");
6var TITLE = __filename.replace(/^.*\//, "");
7
8var data = require("./example.json");
9
10describe(TITLE, function() {
11 test("msgpack", function(they) {
12 assert.deepEqual(they.unpack(msgpack.encode(data)), data);
13 assert.deepEqual(msgpack.decode(Buffer(they.pack(data))), data);
14 });
15
16 test("msgpack-js", function(they) {
17 assert.deepEqual(they.decode(msgpack.encode(data)), data);
18 assert.deepEqual(msgpack.decode(Buffer(they.encode(data))), data);
19 });
20
21 test("msgpack-js-v5", function(they) {
22 assert.deepEqual(they.decode(msgpack.encode(data)), data);
23 assert.deepEqual(msgpack.decode(Buffer(they.encode(data))), data);
24 });
25
26 test("msgpack5", function(they) {
27 they = they();
28 assert.deepEqual(they.decode(msgpack.encode(data)), data);
29 assert.deepEqual(msgpack.decode(Buffer(they.encode(data))), data);
30 });
31
32 test("notepack", function(they) {
33 assert.deepEqual(they.decode(msgpack.encode(data)), data);
34 assert.deepEqual(msgpack.decode(Buffer(they.encode(data))), data);
35 });
36
37 test("msgpack-unpack", function(they) {
38 assert.deepEqual(they(msgpack.encode(data)), data);
39 });
40
41 test("msgpack.codec", function(they) {
42 they = they.msgpack;
43 assert.deepEqual(they.unpack(msgpack.encode(data)), data);
44 assert.deepEqual(msgpack.decode(Buffer(they.pack(data))), data);
45 });
46});
47
48function test(name, func) {
49 var they;
50 var method = it;
51 try {
52 they = require(name);
53 } catch (e) {
54 method = it.skip;
55 name += ": " + e;
56 }
57 method(name, func.bind(null, they));
58}