it("can run a get request", function(next) { mesh.open(http({ request: request })).on("end", function() { expect(requests[0].method).to.be("post"); expect(requests[0].uri).to.be("/ab"); next(); }).end(mesh.operation("insert", { path: "/ab" })); });
it("can customize the methods", function(next) { var stream = mesh.open(http({ request: request, method: function(operation) { return { "insert" : "a", "update" : "b", "load" : "c", "remove" : "d" }[operation.name]; } })); stream.on("end", function() { expect(requests[0].method).to.be("a"); expect(requests[1].method).to.be("b"); expect(requests[2].method).to.be("c"); expect(requests[3].method).to.be("d"); next(); }); stream.write(mesh.operation("insert", { path: "/ab" })); stream.write(mesh.operation("update", { path: "/ab" })); stream.write(mesh.operation("load", { path: "/ab" })); stream.end(mesh.operation("remove", { path: "/ab" })); });
xit("doesn't re-emit the same incomming operation", function(next) { var i = 0; var em = new EventEmitter(); var bus = ros(em.on.bind(em, "message"), em.emit.bind(em, "message"), mesh.wrap(function(operation, next) { i++; next(void 0, operation); })); bus = mesh.tailable(bus); bus(mesh.op("tail")).pipe(mesh.open(bus)); em.emit("message", mesh.op("abba")); setTimeout(function() { expect(i).to.be(0); return next(); }, 1); });