wildfire chat server source initial submit
This commit is contained in:
+37
@@ -0,0 +1,37 @@
|
||||
var tape = require("tape");
|
||||
|
||||
var protobuf = require("../..");
|
||||
|
||||
tape.test("load sync", function(test) {
|
||||
var root = protobuf.loadSync("tests/data/common.proto");
|
||||
|
||||
test.ok(root.lookup("Something"), "should parse message Something");
|
||||
|
||||
test.throws(function() {
|
||||
protobuf.loadSync("tests/data/__NOTFOUND__", root);
|
||||
}, Error, "should throw if not found");
|
||||
|
||||
var isNode = protobuf.util.isNode;
|
||||
try {
|
||||
protobuf.util.isNode = false;
|
||||
test.throws(function() {
|
||||
protobuf.loadSync("tests/data/common.proto");
|
||||
}, "should throw when not running under node");
|
||||
} finally {
|
||||
protobuf.util.isNode = isNode;
|
||||
}
|
||||
|
||||
test.throws(function() {
|
||||
protobuf.loadSync("tests/data/invalid.proto");
|
||||
}, Error, "should throw when trying to load an invalid proto");
|
||||
|
||||
test.throws(function() {
|
||||
protobuf.loadSync("tests/data/invalid.json");
|
||||
}, Error, "should throw when trying to load invalid json");
|
||||
|
||||
root = protobuf.loadSync("tests/data/weak.proto");
|
||||
test.ok(root.files.indexOf("tests/data/NOT_FOUND") > -1, "should ignore missing weak protos and remember them");
|
||||
test.ok(root.files.indexOf("google/protobuf/any.proto") > -1, "should still load other protos when ignoring weak protos");
|
||||
|
||||
test.end();
|
||||
});
|
||||
+88
@@ -0,0 +1,88 @@
|
||||
var fs = require("fs"),
|
||||
path = require("path"),
|
||||
vm = require("vm"),
|
||||
long = require("long"),
|
||||
tape = require("tape");
|
||||
|
||||
var distPath = path.join(__dirname, "..", "..", "dist");
|
||||
|
||||
[
|
||||
{
|
||||
name: "full",
|
||||
data: fs.readFileSync(path.join(distPath, "protobuf.min.js")).toString("utf8")
|
||||
},
|
||||
{
|
||||
name: "light",
|
||||
data: fs.readFileSync(path.join(distPath, "light/protobuf.min.js")).toString("utf8")
|
||||
},
|
||||
{
|
||||
name: "minimal",
|
||||
data: fs.readFileSync(path.join(distPath, "minimal/protobuf.min.js")).toString("utf8")
|
||||
}
|
||||
]
|
||||
.forEach(function(dist) {
|
||||
|
||||
tape.test(dist.name + " build", function(test) {
|
||||
|
||||
test.test(test.name + " - script tags", function(test) {
|
||||
var sandbox;
|
||||
|
||||
var dcodeIO = { Long: long };
|
||||
|
||||
vm.runInNewContext(dist.data, sandbox = {
|
||||
window: {
|
||||
dcodeIO: dcodeIO
|
||||
},
|
||||
dcodeIO: dcodeIO
|
||||
});
|
||||
|
||||
test.ok(sandbox.window.protobuf, "should load the library as a global");
|
||||
test.ok(sandbox.window.protobuf.util.Long, "should load long.js to util");
|
||||
test.end();
|
||||
});
|
||||
|
||||
test.test(test.name + " - webworkers", function(test) {
|
||||
var sandbox;
|
||||
|
||||
var dcodeIO = { Long: long };
|
||||
|
||||
vm.runInNewContext(dist.data, sandbox = {
|
||||
self: {
|
||||
dcodeIO: dcodeIO
|
||||
},
|
||||
dcodeIO: dcodeIO
|
||||
});
|
||||
|
||||
test.ok(sandbox.self.protobuf, "should load the library as a global");
|
||||
test.ok(sandbox.self.protobuf.util.Long, "should load long.js to util");
|
||||
test.end();
|
||||
});
|
||||
|
||||
test.test(test.name + " - amd loaders", function(test) {
|
||||
var sandbox;
|
||||
|
||||
function fakeDefine(deps, factory) {
|
||||
test.same(deps, [ "long" ], "should request long.js as a dependency");
|
||||
test.notOk(sandbox.window.protobuf.util.Long, "should not have loaded long.js before calling the factory function");
|
||||
factory(long);
|
||||
test.ok(sandbox.window.protobuf.util.Long, "should have loaded long.js after calling the factory function");
|
||||
}
|
||||
fakeDefine.amd = true;
|
||||
|
||||
vm.runInNewContext(dist.data, sandbox = {
|
||||
define: fakeDefine,
|
||||
window: {},
|
||||
require: undefined,
|
||||
console: console
|
||||
});
|
||||
|
||||
test.ok(sandbox.window.protobuf, "should load the library as a global");
|
||||
test.end();
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
// commonjs uses ./src
|
||||
Executable
+1
@@ -0,0 +1 @@
|
||||
require("../../lib/fetch/tests"); // requires fs
|
||||
Executable
+1
@@ -0,0 +1 @@
|
||||
require("../../lib/float/tests"); // requires node for modified global envs
|
||||
Executable
+1
@@ -0,0 +1 @@
|
||||
require("../../lib/utf8/tests"); // requires fs to load the test file
|
||||
Reference in New Issue
Block a user