Fakultas Ilmu Komputer UI

Commit 865ff315 authored by Muhammad At Thoriq's avatar Muhammad At Thoriq
Browse files

Merge branch '1606918484-205' into 'master'

1606918484 205

Closes #205

See merge request !245
parents 1c45ba72 0c2fdb97
Pipeline #26710 passed with stages
in 14 minutes and 47 seconds
import React from 'react'; import React from 'react';
import ReactTestUtils from 'react-dom/test-utils'; import ReactTestUtils from 'react-dom/test-utils';
import fetchMock from 'fetch-mock';
import FeedbackPage from '../FeedbackPage'; import FeedbackPage from '../FeedbackPage';
describe('FeedbackPage', () => { describe('FeedbackPage', () => {
...@@ -18,4 +19,50 @@ describe('FeedbackPage', () => { ...@@ -18,4 +19,50 @@ describe('FeedbackPage', () => {
expect(titleh1.textContent).to.equal('Berikan Umpan Balik'); expect(titleh1.textContent).to.equal('Berikan Umpan Balik');
expect(titleh2.textContent).to.equal('Silahkan berikan umpan balik atas layanan yang disediakan oleh KaPe'); expect(titleh2.textContent).to.equal('Silahkan berikan umpan balik atas layanan yang disediakan oleh KaPe');
}); });
it('handle title feedback input without problem', () => {
const feedbackPage = ReactTestUtils.renderIntoDocument(
<FeedbackPage />,
);
const titleNode = ReactTestUtils.scryRenderedDOMComponentsWithTag(feedbackPage, 'input')[0];
const title = "Halo";
titleNode.value = title;
ReactTestUtils.Simulate.change(titleNode, { target: { name: "title", value: title } });
expect(titleNode.value).to.equal(title);
expect(feedbackPage.state.title).to.equal(title);
});
it('handle content feedback input without problem', () => {
const feedbackPage = ReactTestUtils.renderIntoDocument(
<FeedbackPage />,
);
const contentNode = ReactTestUtils.scryRenderedDOMComponentsWithTag(feedbackPage, 'TextArea')[0];
const content = "Good";
contentNode.value = content;
ReactTestUtils.Simulate.change(contentNode, { target: { name: "content", value: content } });
expect(contentNode.value).to.equal(content);
expect(feedbackPage.state.content).to.equal(content);
});
it('submit without problem', () => {
fetchMock.post('*', {});
const feedbackPage = ReactTestUtils.renderIntoDocument(
<FeedbackPage />,
);
feedbackPage.state = {title:'halo', content:'good'};
const form = ReactTestUtils.findRenderedDOMComponentWithTag(feedbackPage, 'Form');
ReactTestUtils.Simulate.submit(form);
fetchMock.restore();
});
it('render without problem when submit error', () => {
fetchMock.post('*', 404);
const feedbackPage = ReactTestUtils.renderIntoDocument(
<FeedbackPage />,
);
feedbackPage.state = {title:'halo', content:'good'};
const form = ReactTestUtils.findRenderedDOMComponentWithTag(feedbackPage, 'Form');
ReactTestUtils.Simulate.submit(form);
fetchMock.restore();
})
}); });
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment