В следующем примере Button.js , где создается класс JavaScript :
import htmlToElement from './htmlToElement';
class Button {
constructor() {
this._html = htmlToElement('<button>simple html</button>');
}
render() {
return this._html;
}
}
Вход . / Button.spec.js
describe('Rectangle...', function() {
it(`should be a class constructor..`, function() {
// how to test against a specific type?
expect(new Button().render()).to.be('HTMLButtonElement');
});
});
// note: mocha and chai are included, jsdom is used also. So the button is rendering.
Как проверить это, если возвращаемое значение функции рендеринга является HTMLButtonElement?