protobuf.js/tests/package-static.js
2016-12-09 17:06:56 +01:00

37 lines
951 B
JavaScript

var tape = require("tape");
var protobuf = require(".."),
pkg = require("../package.json");
tape.test("package.json (static)", function(test) {
var root = require("./data/package.js");
var Package = root.Package,
Repository = root.Package.Repository;
var myPackage = new Package(pkg);
test.test("runtime message", function(test) {
test.ok(myPackage instanceof Package, "should extend Package");
test.deepEqual(myPackage, pkg, "should have equal contents");
test.end();
});
test.test("decoded message", function(test) {
var decoded = Package.decode(Package.encode(myPackage).finish());
test.ok(decoded instanceof Package, "should extend Package");
test.ok(decoded.repository instanceof Repository, "submessage should extend Repository");
test.deepEqual(decoded, pkg, "should have equal contents");
test.end();
});
test.end();
});