Skip to content
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

Open
wants to merge 9 commits into
base: Tsyganov_Vladislav_Vasilevich
Choose a base branch
from

Conversation

N-N0th1n9
Copy link

CodeWars yse

@N-N0th1n9 N-N0th1n9 changed the title Tsyganov vladislav vasilevich CodeWars yse Sep 30, 2023
@N-N0th1n9
Copy link
Author

Цыганов Влад 2/42

@N-N0th1n9 N-N0th1n9 changed the title CodeWars yse CodeWars and RpgSaga yse Oct 1, 2023
@N-N0th1n9 N-N0th1n9 changed the title CodeWars and RpgSaga yse CodeWars and Fox class yse Oct 9, 2023
export default class Fox {
private readonly aName: string;
private aYear: number;
color: string;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔕 Выглядит как enum


static createFoxWithoutInfo(): Fox {
const fox = new Fox('Unknown Fox', 'Unknown Color');
delete fox.year;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

удаление свойств не самая лучшая практика

console.log(`${this.name} hunts ${prey}`);
}

static createFoxWithoutInfo(): Fox {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

выглядит очень странно, сделайте просто вариацию конструктора, которая позволяет работать без указанного поля

Comment on lines 53 to 55
makeSound(): void {
console.log('The fox makes a squeaky sound.');
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

лучше возвращать строковое представление, иначе протестировать не получится

this.aYear = year >= 2000 && year < 2023 ? year : this.aYear >= 2000 && this.aYear < 2023 ? this.aYear : 2000;
}

infoAboutFox(): void {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

так тут уже понятно что fox - можно просто info


it('should log the correct information about the fox', () => {
const test = new Fox('Foxy', 'Red', 2015);
const consoleSpy = jest.spyOn(console, 'log');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • за spyOn, но все же концептуально лучше чтобы класс возвращал значения а не выводил их в консоль, а за вывод в консоль может кто-то друго отвечать

});
});

describe('Testing fox methods', () => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

можно разнести по файлам, и точно нужно разнести по describe, внутри которого может быть несколько тестов для конкретного метода

}

set year(year: number) {
this.aYear = year >= 2000 && year < 2023 ? year : this.aYear >= 2000 && this.aYear < 2023 ? this.aYear : 2000;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

бросайте уже exception

@N-N0th1n9
Copy link
Author

Я постарался исправить все ошибки кроме первой, так как не понял, как вы хотите из этого сделать enum

@N-N0th1n9 N-N0th1n9 changed the title CodeWars and Fox class yse CodeWars_Fox class_RPGSAGA Jan 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants