-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #442 from inversify/chore/add-decorator-tests
Add http decorator tests
- Loading branch information
Showing
20 changed files
with
978 additions
and
1 deletion.
There are no files selected for viewing
42 changes: 42 additions & 0 deletions
42
packages/http/libraries/core/src/http/decorators/All.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import { afterAll, beforeAll, describe, expect, it, jest } from '@jest/globals'; | ||
|
||
jest.mock('./RequestMethod'); | ||
|
||
import { RequestMethodType } from '../models/RequestMethodType'; | ||
import { ALL } from './All'; | ||
import { requestMethod } from './RequestMethod'; | ||
|
||
describe(ALL.name, () => { | ||
describe('when called', () => { | ||
let pathFixture: string | undefined; | ||
let methodDecoratorFixture: MethodDecorator; | ||
let result: unknown; | ||
|
||
beforeAll(() => { | ||
pathFixture = undefined; | ||
methodDecoratorFixture = {} as MethodDecorator; | ||
|
||
(requestMethod as jest.Mocked<typeof requestMethod>).mockReturnValueOnce( | ||
methodDecoratorFixture, | ||
); | ||
|
||
result = ALL(pathFixture); | ||
}); | ||
|
||
afterAll(() => { | ||
jest.clearAllMocks(); | ||
}); | ||
|
||
it('should call requestMethod', () => { | ||
expect(requestMethod).toHaveBeenCalledTimes(1); | ||
expect(requestMethod).toHaveBeenCalledWith( | ||
RequestMethodType.ALL, | ||
pathFixture, | ||
); | ||
}); | ||
|
||
it('should return a MethodDecorator', () => { | ||
expect(result).toBe(methodDecoratorFixture); | ||
}); | ||
}); | ||
}); |
42 changes: 42 additions & 0 deletions
42
packages/http/libraries/core/src/http/decorators/Body.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import { afterAll, beforeAll, describe, expect, it, jest } from '@jest/globals'; | ||
|
||
jest.mock('./RequestParam'); | ||
|
||
import { RequestMethodParameterType } from '../models/RequestMethodParameterType'; | ||
import { body } from './Body'; | ||
import { requestParam } from './RequestParam'; | ||
|
||
describe(body.name, () => { | ||
describe('when called', () => { | ||
let parameterNameFixture: string | undefined; | ||
let parameterDecoratorFixture: ParameterDecorator; | ||
let result: unknown; | ||
|
||
beforeAll(() => { | ||
parameterNameFixture = undefined; | ||
parameterDecoratorFixture = {} as ParameterDecorator; | ||
|
||
(requestParam as jest.Mocked<typeof requestParam>).mockReturnValueOnce( | ||
parameterDecoratorFixture, | ||
); | ||
|
||
result = body(parameterNameFixture); | ||
}); | ||
|
||
afterAll(() => { | ||
jest.clearAllMocks(); | ||
}); | ||
|
||
it('should call requestParam', () => { | ||
expect(requestParam).toHaveBeenCalledTimes(1); | ||
expect(requestParam).toHaveBeenCalledWith( | ||
RequestMethodParameterType.BODY, | ||
parameterNameFixture, | ||
); | ||
}); | ||
|
||
it('should return a ParameterDecorator', () => { | ||
expect(result).toBe(parameterDecoratorFixture); | ||
}); | ||
}); | ||
}); |
42 changes: 42 additions & 0 deletions
42
packages/http/libraries/core/src/http/decorators/Cookies.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import { afterAll, beforeAll, describe, expect, it, jest } from '@jest/globals'; | ||
|
||
jest.mock('./RequestParam'); | ||
|
||
import { RequestMethodParameterType } from '../models/RequestMethodParameterType'; | ||
import { cookies } from './Cookies'; | ||
import { requestParam } from './RequestParam'; | ||
|
||
describe(cookies.name, () => { | ||
describe('when called', () => { | ||
let parameterNameFixture: string | undefined; | ||
let parameterDecoratorFixture: ParameterDecorator; | ||
let result: unknown; | ||
|
||
beforeAll(() => { | ||
parameterNameFixture = undefined; | ||
parameterDecoratorFixture = {} as ParameterDecorator; | ||
|
||
(requestParam as jest.Mocked<typeof requestParam>).mockReturnValueOnce( | ||
parameterDecoratorFixture, | ||
); | ||
|
||
result = cookies(parameterNameFixture); | ||
}); | ||
|
||
afterAll(() => { | ||
jest.clearAllMocks(); | ||
}); | ||
|
||
it('should call requestParam', () => { | ||
expect(requestParam).toHaveBeenCalledTimes(1); | ||
expect(requestParam).toHaveBeenCalledWith( | ||
RequestMethodParameterType.COOKIES, | ||
parameterNameFixture, | ||
); | ||
}); | ||
|
||
it('should return a ParameterDecorator', () => { | ||
expect(result).toBe(parameterDecoratorFixture); | ||
}); | ||
}); | ||
}); |
42 changes: 42 additions & 0 deletions
42
packages/http/libraries/core/src/http/decorators/Delete.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import { afterAll, beforeAll, describe, expect, it, jest } from '@jest/globals'; | ||
|
||
jest.mock('./RequestMethod'); | ||
|
||
import { RequestMethodType } from '../models/RequestMethodType'; | ||
import { DELETE } from './Delete'; | ||
import { requestMethod } from './RequestMethod'; | ||
|
||
describe(DELETE.name, () => { | ||
describe('when called', () => { | ||
let pathFixture: string | undefined; | ||
let methodDecoratorFixture: MethodDecorator; | ||
let result: unknown; | ||
|
||
beforeAll(() => { | ||
pathFixture = undefined; | ||
methodDecoratorFixture = {} as MethodDecorator; | ||
|
||
(requestMethod as jest.Mocked<typeof requestMethod>).mockReturnValueOnce( | ||
methodDecoratorFixture, | ||
); | ||
|
||
result = DELETE(pathFixture); | ||
}); | ||
|
||
afterAll(() => { | ||
jest.clearAllMocks(); | ||
}); | ||
|
||
it('should call requestMethod', () => { | ||
expect(requestMethod).toHaveBeenCalledTimes(1); | ||
expect(requestMethod).toHaveBeenCalledWith( | ||
RequestMethodType.DELETE, | ||
pathFixture, | ||
); | ||
}); | ||
|
||
it('should return a MethodDecorator', () => { | ||
expect(result).toBe(methodDecoratorFixture); | ||
}); | ||
}); | ||
}); |
42 changes: 42 additions & 0 deletions
42
packages/http/libraries/core/src/http/decorators/Get.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import { afterAll, beforeAll, describe, expect, it, jest } from '@jest/globals'; | ||
|
||
jest.mock('./RequestMethod'); | ||
|
||
import { RequestMethodType } from '../models/RequestMethodType'; | ||
import { GET } from './Get'; | ||
import { requestMethod } from './RequestMethod'; | ||
|
||
describe(GET.name, () => { | ||
describe('when called', () => { | ||
let pathFixture: string | undefined; | ||
let methodDecoratorFixture: MethodDecorator; | ||
let result: unknown; | ||
|
||
beforeAll(() => { | ||
pathFixture = undefined; | ||
methodDecoratorFixture = {} as MethodDecorator; | ||
|
||
(requestMethod as jest.Mocked<typeof requestMethod>).mockReturnValueOnce( | ||
methodDecoratorFixture, | ||
); | ||
|
||
result = GET(pathFixture); | ||
}); | ||
|
||
afterAll(() => { | ||
jest.clearAllMocks(); | ||
}); | ||
|
||
it('should call requestMethod', () => { | ||
expect(requestMethod).toHaveBeenCalledTimes(1); | ||
expect(requestMethod).toHaveBeenCalledWith( | ||
RequestMethodType.GET, | ||
pathFixture, | ||
); | ||
}); | ||
|
||
it('should return a MethodDecorator', () => { | ||
expect(result).toBe(methodDecoratorFixture); | ||
}); | ||
}); | ||
}); |
42 changes: 42 additions & 0 deletions
42
packages/http/libraries/core/src/http/decorators/Head.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import { afterAll, beforeAll, describe, expect, it, jest } from '@jest/globals'; | ||
|
||
jest.mock('./RequestMethod'); | ||
|
||
import { RequestMethodType } from '../models/RequestMethodType'; | ||
import { HEAD } from './Head'; | ||
import { requestMethod } from './RequestMethod'; | ||
|
||
describe(HEAD.name, () => { | ||
describe('when called', () => { | ||
let pathFixture: string | undefined; | ||
let methodDecoratorFixture: MethodDecorator; | ||
let result: unknown; | ||
|
||
beforeAll(() => { | ||
pathFixture = undefined; | ||
methodDecoratorFixture = {} as MethodDecorator; | ||
|
||
(requestMethod as jest.Mocked<typeof requestMethod>).mockReturnValueOnce( | ||
methodDecoratorFixture, | ||
); | ||
|
||
result = HEAD(pathFixture); | ||
}); | ||
|
||
afterAll(() => { | ||
jest.clearAllMocks(); | ||
}); | ||
|
||
it('should call requestMethod', () => { | ||
expect(requestMethod).toHaveBeenCalledTimes(1); | ||
expect(requestMethod).toHaveBeenCalledWith( | ||
RequestMethodType.HEAD, | ||
pathFixture, | ||
); | ||
}); | ||
|
||
it('should return a MethodDecorator', () => { | ||
expect(result).toBe(methodDecoratorFixture); | ||
}); | ||
}); | ||
}); |
42 changes: 42 additions & 0 deletions
42
packages/http/libraries/core/src/http/decorators/Headers.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import { afterAll, beforeAll, describe, expect, it, jest } from '@jest/globals'; | ||
|
||
jest.mock('./RequestParam'); | ||
|
||
import { RequestMethodParameterType } from '../models/RequestMethodParameterType'; | ||
import { headers } from './Headers'; | ||
import { requestParam } from './RequestParam'; | ||
|
||
describe(headers.name, () => { | ||
describe('when called', () => { | ||
let parameterNameFixture: string | undefined; | ||
let parameterDecoratorFixture: ParameterDecorator; | ||
let result: unknown; | ||
|
||
beforeAll(() => { | ||
parameterNameFixture = undefined; | ||
parameterDecoratorFixture = {} as ParameterDecorator; | ||
|
||
(requestParam as jest.Mocked<typeof requestParam>).mockReturnValueOnce( | ||
parameterDecoratorFixture, | ||
); | ||
|
||
result = headers(parameterNameFixture); | ||
}); | ||
|
||
afterAll(() => { | ||
jest.clearAllMocks(); | ||
}); | ||
|
||
it('should call requestParam', () => { | ||
expect(requestParam).toHaveBeenCalledTimes(1); | ||
expect(requestParam).toHaveBeenCalledWith( | ||
RequestMethodParameterType.HEADERS, | ||
parameterNameFixture, | ||
); | ||
}); | ||
|
||
it('should return a ParameterDecorator', () => { | ||
expect(result).toBe(parameterDecoratorFixture); | ||
}); | ||
}); | ||
}); |
39 changes: 39 additions & 0 deletions
39
packages/http/libraries/core/src/http/decorators/Next.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import { afterAll, beforeAll, describe, expect, it, jest } from '@jest/globals'; | ||
|
||
jest.mock('./RequestParam'); | ||
|
||
import { RequestMethodParameterType } from '../models/RequestMethodParameterType'; | ||
import { next } from './Next'; | ||
import { requestParam } from './RequestParam'; | ||
|
||
describe(next.name, () => { | ||
describe('when called', () => { | ||
let parameterDecoratorFixture: ParameterDecorator; | ||
let result: unknown; | ||
|
||
beforeAll(() => { | ||
parameterDecoratorFixture = {} as ParameterDecorator; | ||
|
||
(requestParam as jest.Mocked<typeof requestParam>).mockReturnValueOnce( | ||
parameterDecoratorFixture, | ||
); | ||
|
||
result = next(); | ||
}); | ||
|
||
afterAll(() => { | ||
jest.clearAllMocks(); | ||
}); | ||
|
||
it('should call requestParam', () => { | ||
expect(requestParam).toHaveBeenCalledTimes(1); | ||
expect(requestParam).toHaveBeenCalledWith( | ||
RequestMethodParameterType.NEXT, | ||
); | ||
}); | ||
|
||
it('should return a ParameterDecorator', () => { | ||
expect(result).toBe(parameterDecoratorFixture); | ||
}); | ||
}); | ||
}); |
42 changes: 42 additions & 0 deletions
42
packages/http/libraries/core/src/http/decorators/Options.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import { afterAll, beforeAll, describe, expect, it, jest } from '@jest/globals'; | ||
|
||
jest.mock('./RequestMethod'); | ||
|
||
import { RequestMethodType } from '../models/RequestMethodType'; | ||
import { OPTIONS } from './Options'; | ||
import { requestMethod } from './RequestMethod'; | ||
|
||
describe(OPTIONS.name, () => { | ||
describe('when called', () => { | ||
let pathFixture: string | undefined; | ||
let methodDecoratorFixture: MethodDecorator; | ||
let result: unknown; | ||
|
||
beforeAll(() => { | ||
pathFixture = undefined; | ||
methodDecoratorFixture = {} as MethodDecorator; | ||
|
||
(requestMethod as jest.Mocked<typeof requestMethod>).mockReturnValueOnce( | ||
methodDecoratorFixture, | ||
); | ||
|
||
result = OPTIONS(pathFixture); | ||
}); | ||
|
||
afterAll(() => { | ||
jest.clearAllMocks(); | ||
}); | ||
|
||
it('should call requestMethod', () => { | ||
expect(requestMethod).toHaveBeenCalledTimes(1); | ||
expect(requestMethod).toHaveBeenCalledWith( | ||
RequestMethodType.OPTIONS, | ||
pathFixture, | ||
); | ||
}); | ||
|
||
it('should return a MethodDecorator', () => { | ||
expect(result).toBe(methodDecoratorFixture); | ||
}); | ||
}); | ||
}); |
Oops, something went wrong.