CodeWars_Fox class_RPGSAGA#7
CodeWars_Fox class_RPGSAGA#7N-N0th1n9 wants to merge 9 commits intoISUCT:Tsyganov_Vladislav_Vasilevichfrom
Conversation
|
Цыганов Влад 2/42 |
| export default class Fox { | ||
| private readonly aName: string; | ||
| private aYear: number; | ||
| color: string; |
rpgsaga/saga/src/fox.ts
Outdated
|
|
||
| static createFoxWithoutInfo(): Fox { | ||
| const fox = new Fox('Unknown Fox', 'Unknown Color'); | ||
| delete fox.year; |
There was a problem hiding this comment.
удаление свойств не самая лучшая практика
rpgsaga/saga/src/fox.ts
Outdated
| console.log(`${this.name} hunts ${prey}`); | ||
| } | ||
|
|
||
| static createFoxWithoutInfo(): Fox { |
There was a problem hiding this comment.
выглядит очень странно, сделайте просто вариацию конструктора, которая позволяет работать без указанного поля
rpgsaga/saga/src/fox.ts
Outdated
| makeSound(): void { | ||
| console.log('The fox makes a squeaky sound.'); | ||
| } |
There was a problem hiding this comment.
лучше возвращать строковое представление, иначе протестировать не получится
rpgsaga/saga/src/fox.ts
Outdated
| this.aYear = year >= 2000 && year < 2023 ? year : this.aYear >= 2000 && this.aYear < 2023 ? this.aYear : 2000; | ||
| } | ||
|
|
||
| infoAboutFox(): void { |
There was a problem hiding this comment.
так тут уже понятно что fox - можно просто info
rpgsaga/saga/tests/fox.spec.ts
Outdated
|
|
||
| it('should log the correct information about the fox', () => { | ||
| const test = new Fox('Foxy', 'Red', 2015); | ||
| const consoleSpy = jest.spyOn(console, 'log'); |
There was a problem hiding this comment.
- за spyOn, но все же концептуально лучше чтобы класс возвращал значения а не выводил их в консоль, а за вывод в консоль может кто-то друго отвечать
rpgsaga/saga/tests/fox.spec.ts
Outdated
| }); | ||
| }); | ||
|
|
||
| describe('Testing fox methods', () => { |
There was a problem hiding this comment.
можно разнести по файлам, и точно нужно разнести по describe, внутри которого может быть несколько тестов для конкретного метода
rpgsaga/saga/src/fox.ts
Outdated
| } | ||
|
|
||
| set year(year: number) { | ||
| this.aYear = year >= 2000 && year < 2023 ? year : this.aYear >= 2000 && this.aYear < 2023 ? this.aYear : 2000; |
|
Я постарался исправить все ошибки кроме первой, так как не понял, как вы хотите из этого сделать enum |
CodeWars yse