All files / src/test-routes formdata.ts

0% Statements 0/16
0% Branches 0/2
0% Functions 0/4
0% Lines 0/16

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34                                                                   
import { app, ValidationError } from "../api";
 
app.category("optional", () => {
  app.put("/formdata/stream/uploadfile", "StreamUploadFile", (request) => {
    Iif (!(request.body instanceof Buffer)) {
      throw new ValidationError(`Expected binary body but got  ${typeof request.body}`, undefined, request.body);
    }
    return {
      status: 200,
      body: {
        contentType: "application/text",
        rawContent: request.body.toString(),
      },
    };
  });
  app.post("/formsdataurlencoded/pet/add/:petId", "UpdatePetWithForm", (request) => {
    const petId = request.params.petId;
    Iif (petId !== "1") {
      throw new ValidationError(`Expected petID 1 but got ${petId}`, undefined, request.params);
    }
    request.expect.containsHeader("content-type", "application/x-www-form-urlencoded");
    request.expect.bodyEquals({ pet_type: "dog", pet_food: "meat", name: "Fido", pet_age: "42" });
    return {
      status: 200,
    };
  });
  app.post("/formsdataurlencoded/partialConstantBody", "UrlEncodedDataWithPartialConstantBody", (request) => {
    request.expect.bodyEquals({ grant_type: "access_token", access_token: "foo", service: "bar" });
    return {
      status: 200,
    };
  });
});