Skip to content

Commit 4fd4803

Browse files
authored
fix(core): http verbs include OPTIONS (#3661)
1 parent 703a904 commit 4fd4803

2 files changed

Lines changed: 24 additions & 5 deletions

File tree

packages/core/src/types.ts

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1222,15 +1222,23 @@ export type HooksOptions<T = HookCommand | NormalizedHookCommand> = Partial<
12221222

12231223
export type NormalizedHookOptions = HooksOptions<NormalizedHookCommand>;
12241224

1225-
export type Verbs = 'post' | 'put' | 'get' | 'patch' | 'delete' | 'head';
1225+
export type Verbs =
1226+
| 'get'
1227+
| 'put'
1228+
| 'post'
1229+
| 'delete'
1230+
| 'options'
1231+
| 'head'
1232+
| 'patch';
12261233

12271234
export const Verbs = {
1228-
POST: 'post' as Verbs,
1229-
PUT: 'put' as Verbs,
12301235
GET: 'get' as Verbs,
1231-
PATCH: 'patch' as Verbs,
1236+
PUT: 'put' as Verbs,
1237+
POST: 'post' as Verbs,
12321238
DELETE: 'delete' as Verbs,
1239+
OPTIONS: 'options' as Verbs,
12331240
HEAD: 'head' as Verbs,
1241+
PATCH: 'patch' as Verbs,
12341242
};
12351243

12361244
/**

packages/core/src/utils/assertion.test.ts

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,18 @@ describe('assertion testing', () => {
7171

7272
it('checks for verbs', () => {
7373
expect(isVerb(Verbs.GET)).toBeTruthy();
74-
expect(isVerb('options')).toBeFalsy();
74+
expect(isVerb(Verbs.PUT)).toBeTruthy();
75+
expect(isVerb(Verbs.POST)).toBeTruthy();
76+
expect(isVerb(Verbs.DELETE)).toBeTruthy();
77+
expect(isVerb(Verbs.OPTIONS)).toBeTruthy();
78+
expect(isVerb(Verbs.HEAD)).toBeTruthy();
79+
expect(isVerb(Verbs.PATCH)).toBeTruthy();
80+
81+
// Negative checks: casing and unknown verbs
82+
expect(isVerb('unknown')).toBeFalsy();
83+
expect(isVerb('')).toBeFalsy();
84+
expect(isVerb(undefined as unknown as string)).toBeFalsy();
85+
expect(isVerb(null as unknown as string)).toBeFalsy();
7586
});
7687

7788
it('checks for valid URLs', () => {

0 commit comments

Comments
 (0)