My goal is to unit test a simple function using pure JavaScript:
NS.isType = function (type, obj) {
if (obj.constructor && obj.constructor.name) {
return obj.constructor.name === type;
}
return toString.call(obj) === '[object ' + type + ']';
};
I am eager to start practicing unit testing in JavaScript without relying on any framework. I want to grasp the concept through a hands-on example before delving into more comprehensive resources like the O'Reilly book, (2013), which covers unit testing with frameworks.
Could someone guide me on how to unit test the above method using only pure JavaScript without any external library?