-
Notifications
You must be signed in to change notification settings - Fork 5
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 #252 from boostcampwm-2024/test/today-statistic-api
✅ test: Today Statistic Test 작성
- Loading branch information
Showing
3 changed files
with
72 additions
and
134 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
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 { validate } from 'class-validator'; | ||
import { StatisticQueryDto } from '../../../src/statistic/dto/statistic-query.dto'; | ||
|
||
describe('StatisticQueryDto', () => { | ||
it('실수를 입력한다.', async () => { | ||
// given | ||
const dto = new StatisticQueryDto(); | ||
dto.limit = 1.1; | ||
|
||
// when | ||
const errors = await validate(dto); | ||
|
||
// then | ||
expect(errors.length).toBe(1); | ||
expect(errors[0].constraints).toHaveProperty( | ||
'isInt', | ||
'정수로 입력해주세요.', | ||
); | ||
}); | ||
it('문자열을 입력한다.', async () => { | ||
// given | ||
const dto = new StatisticQueryDto(); | ||
dto.limit = 'test' as unknown as number; | ||
|
||
// when | ||
const errors = await validate(dto); | ||
|
||
// then | ||
expect(errors.length).toBe(1); | ||
expect(errors[0].constraints).toHaveProperty( | ||
'isInt', | ||
'정수로 입력해주세요.', | ||
); | ||
}); | ||
it('음수를 입력한다.', async () => { | ||
// given | ||
const dto = new StatisticQueryDto(); | ||
dto.limit = -1; | ||
|
||
// when | ||
const errors = await validate(dto); | ||
|
||
// then | ||
expect(errors.length).toBe(1); | ||
expect(errors[0].constraints).toHaveProperty( | ||
'min', | ||
'limit 값은 1 이상이어야 합니다.', | ||
); | ||
}); | ||
}); |
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