czy mógłby mnie ktos oświecić o co chodzi w testowaniu i jak to się robi mam taki kod js
function count(field,max)
{
field.value = field.value.substr(0,max);
document.getElementById("s"+field.id).innerHTML = max - field.value.length;
}
const textArea = document.getElementById('textareaT');
const inputsParent = document.getElementById("inputsParent");
const inputs = inputsParent.children;
var addEventListeners = (elements, eventType, event) =>
{
const collection = (elements.length) ? elements : Array.of(elements);
for(var element of collection)
{
element.addEventListener(eventType, event);
}
};
function bindToTextArea()
{
var textAreaValue = textArea.value;
const id = parseInt(this.id);
var textAreaAsArray = textAreaValue.split("\n");
textAreaAsArray[id - 1] = this.value;
textArea.value = textAreaAsArray.join("\n");
}
function bindToInputs()
{
var textAreaAsArray = this.value.split("\n");
if(textAreaAsArray.length > inputs.length)
{
var diff = textAreaAsArray.length - inputs.length;
textAreaAsArray.splice(inputs.length, diff);
}
textAreaAsArray.forEach((value, index) =>
{
if(inputs[index].value !== value)
{
const id = inputs[index].id;
const input = document.getElementById(id);
input.value = value;
}
});
}
addEventListeners(inputs, "input", bindToTextArea);
addEventListeners(textArea, "input", bindToInputs);
w jaki sposob mam zrobic na nim testy?