-
Notifications
You must be signed in to change notification settings - Fork 29
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 #36 from storyofams/beta
Release v1.3.0
- Loading branch information
Showing
37 changed files
with
408 additions
and
99 deletions.
There are no files selected for viewing
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 |
---|---|---|
|
@@ -24,6 +24,3 @@ | |
npm-debug.log* | ||
yarn-debug.log* | ||
yarn-error.log* | ||
|
||
# storybook | ||
storybook-static |
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
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 |
---|---|---|
@@ -1,10 +1,10 @@ | ||
{ | ||
"moduleFileExtensions": ["js", "json", "ts"], | ||
"rootDir": "lib", | ||
"rootDir": ".", | ||
"testRegex": ".(spec|test).ts$", | ||
"transform": { | ||
"^.+\\.(t|j)s$": "ts-jest" | ||
}, | ||
"coverageDirectory": "../coverage", | ||
"coverageDirectory": "coverage", | ||
"testEnvironment": "node" | ||
} |
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 |
---|---|---|
|
@@ -2,4 +2,4 @@ | |
"rules": { | ||
"@typescript-eslint/ban-types": "off" | ||
} | ||
} | ||
} |
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
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
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
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
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
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
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,50 @@ | ||
import { | ||
HttpException, | ||
BadRequestException, | ||
InternalServerErrorException, | ||
NotFoundException, | ||
UnauthorizedException, | ||
UnprocessableEntityException | ||
} from '.'; | ||
|
||
describe('HttpException', () => { | ||
it(`Should use 'HttpException' as name`, () => | ||
expect(new HttpException(500)).toHaveProperty('name', 'HttpException')); | ||
|
||
it('Should set the given number as statusCode', () => | ||
expect(new HttpException(500)).toHaveProperty('statusCode', 500)); | ||
|
||
it('Should set the given string as message', () => | ||
expect(new HttpException(403, 'Forbidden')).toHaveProperty('message', 'Forbidden')); | ||
|
||
it('Should set the given array of strings as errors', () => | ||
expect( | ||
new HttpException(400, 'Bad request', ['First name is required', 'Last name is required']) | ||
).toHaveProperty('errors', ['First name is required', 'Last name is required'])); | ||
|
||
it('Should set the name, statusCode, message and errors', () => | ||
expect(new HttpException(400, 'Bad request', ['Invalid email address'])).toMatchObject({ | ||
name: 'HttpException', | ||
statusCode: 400, | ||
message: 'Bad request', | ||
errors: ['Invalid email address'] | ||
})); | ||
|
||
describe('Default errors', () => { | ||
it('Should set the default status codes', () => { | ||
expect(new BadRequestException()).toHaveProperty('statusCode', 400); | ||
expect(new InternalServerErrorException()).toHaveProperty('statusCode', 500); | ||
expect(new NotFoundException()).toHaveProperty('statusCode', 404); | ||
expect(new UnauthorizedException()).toHaveProperty('statusCode', 401); | ||
expect(new UnprocessableEntityException()).toHaveProperty('statusCode', 422); | ||
}); | ||
|
||
it('Should set the default error messages', () => { | ||
expect(new BadRequestException()).toHaveProperty('message', 'Bad Request'); | ||
expect(new InternalServerErrorException()).toHaveProperty('message', 'Internal Server Error'); | ||
expect(new NotFoundException()).toHaveProperty('message', 'Not Found'); | ||
expect(new UnauthorizedException()).toHaveProperty('message', 'Unauthorized'); | ||
expect(new UnprocessableEntityException()).toHaveProperty('message', 'Unprocessable Entity'); | ||
}); | ||
}); | ||
}); |
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,9 @@ | ||
import { HttpException } from './HttpException'; | ||
|
||
export class InternalServerErrorException extends HttpException { | ||
public name = 'InternalServerErrorException'; | ||
|
||
public constructor(message: string = 'Internal Server Error') { | ||
super(500, message); | ||
} | ||
} |
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 |
---|---|---|
@@ -1,9 +1,9 @@ | ||
import { HttpException } from './HttpException'; | ||
|
||
export class NotFoundException extends HttpException { | ||
public name = 'BadRequestException'; | ||
public name = 'NotFoundException'; | ||
|
||
public constructor(message?: string) { | ||
public constructor(message: string = 'Not Found') { | ||
super(404, message); | ||
} | ||
} |
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,9 @@ | ||
import { HttpException } from './HttpException'; | ||
|
||
export class UnauthorizedException extends HttpException { | ||
public name = 'UnauthorizedException'; | ||
|
||
public constructor(message: string = 'Unauthorized') { | ||
super(401, message); | ||
} | ||
} |
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,9 @@ | ||
import { HttpException } from './HttpException'; | ||
|
||
export class UnprocessableEntityException extends HttpException { | ||
public name = 'UnprocessableEntityException'; | ||
|
||
public constructor(message: string = 'Unprocessable Entity', errors?: string[]) { | ||
super(422, message, errors); | ||
} | ||
} |
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 |
---|---|---|
@@ -1,3 +1,6 @@ | ||
export * from './HttpException'; | ||
export * from './NotFoundException'; | ||
export * from './BadRequestException'; | ||
export * from './InternalServerErrorException'; | ||
export * from './NotFoundException'; | ||
export * from './UnauthorizedException'; | ||
export * from './UnprocessableEntityException'; |
Oops, something went wrong.