Вопрос заключается в следующем: «Этот тест проверяет, что конструктор в классе Command правильно устанавливает свойство commandType в новом объекте.»
Я не уверен, как его настроить
Вот код, который у меня есть, который терпит неудачу. Первый тест работает, но во-вторых, нам говорят, что нам не нужно использовать assert.throws, поэтому я попытался использовать строгие тесты, но не уверен, как его настроить.
const assert = require('assert');
const Command = require('../command.js');
describe("Command class", function() {
it("throws error if command type is NOT passed into constructor as the first parameter", function() {
assert.throws(
function() {
new Command();
},
{
message: 'Command type required.'
}
);
});
it("constructor should set command type",function(){
let contructorCheck = Command(commandtype, 7);
assert.sctrictEqual(contructorCheck, "commandtype")
});
});
, и этокласс, который я тестирую
class Command {
constructor(commandType, value) {
this.commandType = commandType;
if (!commandType) {
throw Error("Command type required.");
}
this.value = value;
}
}