Answer the question
In order to leave comments, you need to log in
How to check DOM element with jest?
there is a function that adds or removes a class from an element:
export default function activeButtonClick(button) {
if (button.classList.contains('active')) {
button.classList.remove('active');
} else {
button.classList.add('active');
}
}
module.exports = activeButtonClick;
const activeBtn = require('./activeBtnClick');
const pencil = document.getElementById('pencil');
describe("activeBtnClick", () => {
it("adds class to the button", () => {
??
});
});
Answer the question
In order to leave comments, you need to log in
const activeBtn = require('./activeBtnClick');
const pencil = document.getElementById('pencil');
describe("activeBtnClick", () => {
it("adds class to the button", () => {
except(button.classList.contains('active')).toEqual(true);
});
});
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question