Skip to content

Commit 3b2d2f6

Browse files
committed
setup: disable tweet when no text
1 parent 1cbbb5f commit 3b2d2f6

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

src/tests/components/MessageForm.test.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,4 +34,19 @@ describe("MessageForm", () => {
3434
`${text.length} / ${MAX_MESSAGE_TEXT_LENGTH}`
3535
);
3636
});
37+
38+
test("disables tweet button when text is empty", () => {
39+
const utils = render(<MessageForm user={USER} />);
40+
const button = utils.getByRole("tweet");
41+
expect(button.disabled).toBe(true);
42+
});
43+
44+
test("updates with user typing", () => {
45+
const text = "A";
46+
const utils = render(<MessageForm user={USER} />);
47+
const input = utils.getByLabelText("message-form");
48+
fireEvent.change(input, { target: { value: text } });
49+
const button = utils.getByRole("tweet");
50+
expect(button.disabled).toBe(false);
51+
});
3752
});

0 commit comments

Comments
 (0)