-
Notifications
You must be signed in to change notification settings - Fork 33
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
Бёрдов Дмитрий #36
base: master
Are you sure you want to change the base?
Бёрдов Дмитрий #36
Conversation
…м, на количество элементов в массиве, является ли элемент массива числом, лежит ли элемент массива в диапазоне от 1 до 6
Файл компилируется, расширено покрытие тестами. |
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.
Переделай работу с ошибками, после этого посмотрю ещё раз
getPokerHand.js
Outdated
return 'Покер'; | ||
try { | ||
|
||
dice.sort(); |
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.
Проверить является ли переменная массивом можно оператором Array.isArray(dice)
getPokerHand.js
Outdated
catch (err) { | ||
|
||
res = ('Не массив'); | ||
return res; |
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.
Ошибку надо не возвращать return
а выбрасывать throw
:
throw new Error('Не массив');
}); | ||
|
||
|
||
describe('getPokerHand', () => { |
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
а внутри него несколько it
:
describe('getPokerHand', () => {
it('should ...', () => {});
it('should ...', () => {});
});
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.
Это замечание всё ещё актуально
Переделана работа с ошибками, из TODO - рефакторинг файла с тестами. |
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.
Уже гораздо лучше!
|
||
j = 0; | ||
for(var i = 1; i<5; i++){ | ||
if ((isNaN(dice[i])) || (isNaN(dice[j]))) { |
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('getPokerHand', () => { |
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.
Это замечание всё ещё актуально
} catch (error) { | ||
assert.equal(error.message, 'Не массив'); | ||
} | ||
}) |
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.
Попробуй воспользоваться assert.throws
Твои тесты станут компактнее
Документацию можно почитать по ссылке https://nodejs.org/api/assert.html#assert_assert_throws_block_error_message
No description provided.