Skip to content
This repository has been archived by the owner on Nov 8, 2024. It is now read-only.

Commit

Permalink
fix: uses "HTTPMethod" enum over "RESTMethod"
Browse files Browse the repository at this point in the history
  • Loading branch information
artem-zakharchenko committed Oct 22, 2019
1 parent bdd0c21 commit 875fc45
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 20 deletions.
4 changes: 2 additions & 2 deletions packages/dredd/lib/general.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export enum RESTMethod {
export enum HTTPMethod {
CONNECT = 'CONNECT',
OPTIONS = 'OPTIONS',
POST = 'POST',
Expand Down Expand Up @@ -49,7 +49,7 @@ export interface Transaction {
}

export interface TransactionRequest {
method: RESTMethod;
method: HTTPMethod;
url: string;
body?: string;
bodyEncoding?: BodyEncoding;
Expand Down
24 changes: 12 additions & 12 deletions packages/dredd/lib/sortTransactions.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import { RESTMethod, Transaction } from './general';

const sortedMethods: RESTMethod[] = [
RESTMethod.CONNECT,
RESTMethod.OPTIONS,
RESTMethod.POST,
RESTMethod.GET,
RESTMethod.HEAD,
RESTMethod.PUT,
RESTMethod.PATCH,
RESTMethod.DELETE,
RESTMethod.TRACE,
import { HTTPMethod, Transaction } from './general';

const sortedMethods: HTTPMethod[] = [
HTTPMethod.CONNECT,
HTTPMethod.OPTIONS,
HTTPMethod.POST,
HTTPMethod.GET,
HTTPMethod.HEAD,
HTTPMethod.PUT,
HTTPMethod.PATCH,
HTTPMethod.DELETE,
HTTPMethod.TRACE,
];

// Often, API description is arranged with a sequence of methods that lends
Expand Down
12 changes: 6 additions & 6 deletions packages/dredd/test/unit/sortTransactions-test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import R from 'ramda';
import { expect } from 'chai';
import sortTransactions from '../../lib/sortTransactions';
import { Transaction, RESTMethod } from '../../lib/general';
import { Transaction, HTTPMethod } from '../../lib/general';

const createTransaction = (transaction: Partial<Transaction>) => {
return R.mergeDeepRight<Partial<Transaction>>({
Expand All @@ -10,10 +10,10 @@ const createTransaction = (transaction: Partial<Transaction>) => {
})(transaction);
};

const transactions = Object.keys(RESTMethod).reduce<
Record<RESTMethod, Transaction>
const transactions = Object.keys(HTTPMethod).reduce<
Record<HTTPMethod, Transaction>
>(
(acc, method: RESTMethod) => {
(acc, method: HTTPMethod) => {
return R.assoc(
method,
createTransaction({
Expand Down Expand Up @@ -61,15 +61,15 @@ describe('sortTransactions', () => {
const getOne = createTransaction({
id: 'one',
request: {
method: RESTMethod.GET,
method: HTTPMethod.GET,
url: '/endpoint',
},
});

const getTwo = createTransaction({
id: 'two',
request: {
method: RESTMethod.GET,
method: HTTPMethod.GET,
url: '/endpoint',
},
});
Expand Down

0 comments on commit 875fc45

Please sign in to comment.