|
| 1 | +importReactfrom"react"; |
| 2 | +import{render,fireEvent}from"@testing-library/react"; |
| 3 | +import{MessageForm}from"../../components/MessageForm"; |
| 4 | +import{USER}from"../../config"; |
| 5 | + |
| 6 | +describe("MessageForm",()=>{ |
| 7 | +test("initiates text as empty",()=>{ |
| 8 | +constutils=render(<MessageFormuser={USER}/>); |
| 9 | +constinput=utils.getByLabelText("message-form"); |
| 10 | +expect(input.value).toBe(""); |
| 11 | +}); |
| 12 | + |
| 13 | +test("updates with user typing",()=>{ |
| 14 | +consttext="55555"; |
| 15 | +constutils=render(<MessageFormuser={USER}/>); |
| 16 | +constinput=utils.getByLabelText("message-form"); |
| 17 | +fireEvent.change(input,{target:{value:text}}); |
| 18 | +expect(input.value).toBe(text); |
| 19 | +}); |
| 20 | +}); |