Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add more status codes Closes #2 #15

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion client/src/components/RouteModal/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { updateRoute as updateRouteRequest, createNewRoute } from "../../utils/r
import faker from "faker";

const HTTP_METHOD_LIST = [HttpMethods.GET, HttpMethods.POST, HttpMethods.PUT, HttpMethods.DELETE];
const STATUS_CODES = [StatusCodes.OK, StatusCodes.CREATED, StatusCodes.NO_CONTENT, StatusCodes.BAD_REQUEST, StatusCodes.FORBIDDEN, StatusCodes.INTERNAL_SERVER_ERROR];
const STATUS_CODES = Object.values(StatusCodes);

const Modal = function(props) {
const { onClose = () => {}, route: editedRoute } = props;
Expand Down
3 changes: 2 additions & 1 deletion client/src/components/RouteModal/spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { render, fireEvent, cleanup } from "react-testing-library";
import "jest-dom/extend-expect";
import RouteModal from "./";
import * as utils from "../../utils/routes-api";
import {StatusCodes} from "../../utils/consts";

afterEach(cleanup);

Expand Down Expand Up @@ -64,7 +65,7 @@ describe("Route Modal", () => {
const dropdown = getByLabelText("route-statuscode");
const dropdownOptions = dropdown.children;

expect(dropdownOptions.length).toEqual(6);
expect(dropdownOptions.length).toEqual(Object.keys(StatusCodes).length);

expect(getByValue("200", dropdownOptions)).toBeVisible();
expect(getByValue("201", dropdownOptions)).toBeVisible();
Expand Down
71 changes: 64 additions & 7 deletions client/src/utils/consts/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,69 @@ export const HttpMethods = {
};

export const StatusCodes = {
OK: "200",
CREATED: "201",
NO_CONTENT: "204",
BAD_REQUEST: "400",
FORBIDDEN: "401",
INTERNAL_SERVER_ERROR: "500"
};
"**INFORMATIONAL**": "1xx",
"CONTINUE": "100",
"SWITCHING PROTOCOLS": "101",
"**SUCCESSFUL**": "2xx",
"OK": "200",
"CREATED": "201",
"ACCEPTED": "202",
"NON-AUTHORITATIVE INFORMATION": "203",
"NO CONTENT": "204",
"RESET CONTENT": "205",
"PARTIAL CONTENT": "206",
"**REDIRECTION**": "3xx",
"MULTIPLE CHOICES": "300",
"MOVED PERMANENTLY": "301",
"FOUND": "302",
"SEE OTHER": "303",
"NOT MODIFIED": "304",
"USE PROXY": "305",
"TEMPORARY REDIRECT": "307",
"**CLIENT ERROR**": "4xx",
"BAD_REQUEST": "400",
"UNAUTHORIZED": "401",
"PAYMENT REQUIRED": "402",
"FORBIDDEN": "403",
"NOT FOUND": "404",
"METHOD NOT ALLOWED": "405",
"NOT ACCEPTABLE": "406",
"PROXY AUTHENTICATION REQUIRED": "407",
"REQUEST TIMEOUT": "408",
"CONFLICT": "409",
"GONE": "410",
"LENGTH REQUIRED": "411",
"PRECONDITION FAILED": "412",
"PAYLOAD TOO LARGE": "413",
"URI TOO LONG": "414",
"UNSUPPORTED MEDIA TYPE": "415",
"RANGE NOT SATISFIABLE": "416",
"EXPECTATION FAILED": "417",
"I'M A TEAPOT": "418",
"UPGRADE REQUIRED": "426",
"**SERVER ERROR**": "5xx",
"INTERNAL SERVER ERROR": "500",
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Notice that this no longer has the underscores as previously. Is that going to be a problem?

"NOT IMPLEMENTED": "501",
"BAD GATEWAY": "502",
"SERVICE UNAVAILABLE": "503",
"GATEWAY TIME-OUT": "504",
"HTTP VERSION NOT SUPPORTED": "505",
"PROCESSING": "102",
"MULTI-STATUS": "207",
"IM USED": "226",
"PERMANENT REDIRECT": "308",
"UNPROCESSABLE ENTITY": "422",
"LOCKED": "423",
"FAILED DEPENDENCY": "424",
"PRECONDITION REQUIRED": "428",
"TOO MANY REQUESTS": "429",
"REQUEST HEADER FIELDS TOO LARGE": "431",
"UNAVAILABLE FOR LEGAL REASONS": "451",
"VARIANT ALSO NEGOTIATES": "506",
"INSUFFICIENT STORAGE": "507",
"NETWORK AUTHENTICATION REQUIRED": "511",
"**DEVELOPER ERROR**": "7xx"
}


export const MOCKIT_SERVER_URL = process.env.REACT_APP_MOCKIT_SERVER_URL || "localhost:3000";