diff --git a/dom-merge-conflict/tasks/buttons-and-counter/src/app.js b/dom-merge-conflict/tasks/buttons-and-counter/src/app.js index af608eb6..9d3adf4b 100644 --- a/dom-merge-conflict/tasks/buttons-and-counter/src/app.js +++ b/dom-merge-conflict/tasks/buttons-and-counter/src/app.js @@ -3,6 +3,10 @@ function increment(node) { let current = node.textContent; node.textContent = Number(current) + 1; } +function decrement(node) { + let current = node.textContent; + node.textContent = Number(current) - 1; +} export function App() { const body = document.createElement("body"); @@ -10,7 +14,7 @@ export function App() { const header = document.createElement("header"); header.innerHTML = `

Number Counter

-

A simple counter. Press increment to increase the count by one.

+

A simple counter. Press increment to increase the count by one or decrement to decrease it by one.

`; body.appendChild(header); @@ -18,6 +22,7 @@ export function App() { main.innerHTML = `

0

+ `; body.appendChild(main); @@ -26,6 +31,7 @@ export function App() { button.addEventListener("click", () => { increment(counter); }); - - return body; -} + const decrementButton = body.querySelector("#decrement"); + decrementButton.addEventListener("click", () => { + decrement(counter); + }); diff --git a/dom-merge-conflict/tasks/buttons-and-counter/test/app.test.js b/dom-merge-conflict/tasks/buttons-and-counter/test/app.test.js index 1139e456..6c7fcf6c 100644 --- a/dom-merge-conflict/tasks/buttons-and-counter/test/app.test.js +++ b/dom-merge-conflict/tasks/buttons-and-counter/test/app.test.js @@ -35,7 +35,7 @@ describe("button and counter", () => { expect(getByTestId(container, "counter")).toHaveTextContent(/^2$/); }); - describe.skip("decrement button", () => { + describe("decrement button", () => { test("pressing Decrement decreases the counter", () => { const button = getByRole(container, "button", { name: "Decrement", @@ -54,3 +54,4 @@ describe("button and counter", () => { }); }); }); +