JSFiddle - React, Tailwind, and code Playground
JavaScript
class Vehicle {
constructor(make, model) {
this.make = make;
this.model = model;
}
}
class Car extends Vehicle {
constructor(make, model, doorCount) {
super(make, model);
this.doorCount = doorCount;
}
}
function testCarConstructor() {
console.log('Running test: testCarConstructor');
let wereAnyMocksUsed = false;
const mock = () => { wereAnyMocksUsed = true; }
Vehicle.constructor = mock;
Vehicle.prototype.constructor = mock;
Car.prototype.super = mock;
Car.super = mock;
new Car('Nissan', 'Pulsar', 4);
console.log('Finished test. Were any mocks used?', wereAnyMocksUsed);
}
testCarConstructor();