All files / src/test-routes string.ts

0% Statements 0/50
100% Branches 0/0
0% Functions 0/20
0% Lines 0/50

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 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144                                                                                                                                                                                                                                                                                               
import { app, json } from "../api";
 
app.category("vanilla", () => {
  app.get("/string/null", "getStringNull", (req) => {
    return {
      status: 200,
      body: {
        contentType: "application/json",
        rawContent: undefined,
      },
    };
  });
  app.put("/string/null", "putStringNull", (req) => {
    req.expect.rawBodyEquals(undefined);
    return { status: 200 };
  });
 
  app.get("/string/empty", "getStringEmpty", (req) => {
    return {
      status: 200,
      body: {
        contentType: "application/json",
        rawContent: `""`,
      },
    };
  });
 
  app.put("/string/empty", "putStringEmpty", (req) => {
    req.expect.rawBodyEquals(`""`);
    return { status: 200 };
  });
 
  app.get("/string/notProvided", "getStringNotProvided", (req) => {
    return {
      status: 200,
    };
  });
 
  app.get("/string/whitespace", "getStringWithLeadingAndTrailingWhitespace", (req) => {
    return {
      status: 200,
      body: {
        contentType: "application/json",
        rawContent: '"    Now is the time for all good men to come to the aid of their country    "',
      },
    };
  });
 
  app.put("/string/whitespace", "putStringWithLeadingAndTrailingWhitespace", (req) => {
    req.expect.rawBodyEquals('"    Now is the time for all good men to come to the aid of their country    "');
    return { status: 200 };
  });
 
  app.get("/string/base64UrlEncoding", "getStringBase64UrlEncoded", (req) => {
    return {
      status: 200,
      body: {
        contentType: "application/json",
        rawContent: '"YSBzdHJpbmcgdGhhdCBnZXRzIGVuY29kZWQgd2l0aCBiYXNlNjR1cmw"',
      },
    };
  });
 
  app.put("/string/base64UrlEncoding", "putStringBase64UrlEncoded", (req) => {
    req.expect.rawBodyEquals('"YSBzdHJpbmcgdGhhdCBnZXRzIGVuY29kZWQgd2l0aCBiYXNlNjR1cmw"');
    return { status: 200 };
  });
 
  app.get("/string/base64Encoding", "getStringBase64Encoded", (req) => {
    return {
      status: 200,
      body: {
        contentType: "application/json",
        rawContent: '"YSBzdHJpbmcgdGhhdCBnZXRzIGVuY29kZWQgd2l0aCBiYXNlNjQ="',
      },
    };
  });
 
  app.get("/string/nullBase64UrlEncoding", "getStringNullBase64UrlEncoding", (req) => {
    return { status: 200 };
  });
 
  const MULTIBYTE_BUFFER_BODY =
    "啊齄丂狛狜隣郎隣兀﨩ˊ〞〡¦℡㈱‐ー﹡﹢﹫、〓ⅰⅹ⒈€㈠㈩ⅠⅫ! ̄ぁんァヶΑ︴АЯаяāɡㄅㄩ─╋︵﹄︻︱︳︴ⅰⅹɑɡ〇〾⿻⺁䜣€";
 
  app.get("/string/mbcs", "getStringMultiByteCharacters", (req) => {
    return {
      status: 200,
      body: {
        contentType: "application/json",
        rawContent: `"${MULTIBYTE_BUFFER_BODY}"`,
      },
    };
  });
 
  app.put("/string/mbcs", "putStringMultiByteCharacters", (req) => {
    req.expect.bodyEquals(MULTIBYTE_BUFFER_BODY);
    req.expect.bodyEquals(MULTIBYTE_BUFFER_BODY);
    return { status: 200 };
  });
 
  app.get("/string/enum/notExpandable", "getEnumNotExpandable", (req) => {
    return {
      status: 200,
      body: {
        contentType: "application/json",
        rawContent: '"red color"',
      },
    };
  });
 
  app.put("/string/enum/notExpandable", "putEnumNotExpandable", (req) => {
    req.expect.rawBodyEquals('"red color"');
    return { status: 200 };
  });
 
  app.get("/string/enum/Referenced", "getEnumReferenced", (req) => {
    return {
      status: 200,
      body: {
        contentType: "application/json",
        rawContent: '"red color"',
      },
    };
  });
 
  app.put("/string/enum/Referenced", "putEnumReferenced", (req) => {
    req.expect.rawBodyEquals('"red color"');
    return { status: 200 };
  });
 
  app.get("/string/enum/ReferencedConstant", "getEnumReferencedConstant", (req) => {
    return {
      status: 200,
      body: json({ field1: "Sample String" }),
    };
  });
 
  app.put("/string/enum/ReferencedConstant", "putEnumReferencedConstant", (req) => {
    req.expect.bodyEquals({ ColorConstant: "green-color" });
    return { status: 200 };
  });
});