-
Notifications
You must be signed in to change notification settings - Fork 34
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
CodeWars_Fox class_RPGSAGA #7
base: Tsyganov_Vladislav_Vasilevich
Are you sure you want to change the base?
CodeWars_Fox class_RPGSAGA #7
Conversation
Цыганов Влад 2/42 |
rpgsaga/saga/src/fox.ts
Outdated
export default class Fox { | ||
private readonly aName: string; | ||
private aYear: number; | ||
color: string; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🔕 Выглядит как enum
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
удаление свойств не самая лучшая практика
rpgsaga/saga/src/fox.ts
Outdated
console.log(`${this.name} hunts ${prey}`); | ||
} | ||
|
||
static createFoxWithoutInfo(): Fox { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
выглядит очень странно, сделайте просто вариацию конструктора, которая позволяет работать без указанного поля
rpgsaga/saga/src/fox.ts
Outdated
makeSound(): void { | ||
console.log('The fox makes a squeaky sound.'); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
лучше возвращать строковое представление, иначе протестировать не получится
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
так тут уже понятно что 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- за spyOn, но все же концептуально лучше чтобы класс возвращал значения а не выводил их в консоль, а за вывод в консоль может кто-то друго отвечать
rpgsaga/saga/tests/fox.spec.ts
Outdated
}); | ||
}); | ||
|
||
describe('Testing fox methods', () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
можно разнести по файлам, и точно нужно разнести по 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; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
бросайте уже exception
Я постарался исправить все ошибки кроме первой, так как не понял, как вы хотите из этого сделать enum |
CodeWars yse