Skip to content

Commit ecefa46

Browse files
committed
refactor(name): renamed handlercontex to mockcontext and exported it
1 parent 7b434f5 commit ecefa46

File tree

4 files changed

+9
-8
lines changed

4 files changed

+9
-8
lines changed

src/handler-context.ts renamed to src/mock-context.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ async function delay(ms: number): Promise<any> {
66
});
77
}
88

9-
class HandlerContext {
9+
class MockContext {
1010
private req: MockRequest;
1111
private realFetch: (input: RequestInfo, init?: RequestInit) => Promise<Response>;
1212

@@ -82,4 +82,4 @@ class HandlerContext {
8282
}
8383
}
8484

85-
export default HandlerContext;
85+
export default MockContext;

src/types.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
import MockContext from './handler-context';
1+
import MockContext from './mock-context';
2+
export { default as MockContext } from './mock-context';
23

34
export type Opaque<K, T> = T & { __TYPE__: K };
45

src/yet-another-fetch-mock.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import {
1919
findRequestUrl
2020
} from './internal-utils';
2121
import MatcherUtils from './matcher-utils';
22-
import HandlerContext from './handler-context';
22+
import MockContext from './mock-context';
2323

2424
const defaultConfiguration: Configuration = {
2525
enableFallback: true,
@@ -121,7 +121,7 @@ class FetchMock {
121121

122122
return responseData;
123123
};
124-
const ctx = new HandlerContext(req, this.realFetch);
124+
const ctx = new MockContext(req, this.realFetch);
125125

126126
response = matchingRoute.handler(req, res, ctx);
127127
}

test/handler-context.test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
import 'isomorphic-fetch';
22
import { RequestUrl } from '../src/types';
3-
import HandlerContext from '../src/handler-context';
3+
import MockContext from '../src/mock-context';
44

5-
describe('HandlerContext', () => {
5+
describe('MockContext', () => {
66
const realFetch: (input: RequestInfo, init?: RequestInit) => Promise<Response> = jest.fn();
7-
const handlerContext: HandlerContext = new HandlerContext(
7+
const handlerContext: MockContext = new MockContext(
88
{
99
input: 'http://mock.url',
1010
url: 'http://mock.url' as RequestUrl,

0 commit comments

Comments
 (0)