Ejemplo n.º 1
0
 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" }));
 });
Ejemplo n.º 2
0
  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" }));

  });
Ejemplo n.º 3
0
  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);
  });