Skip to content

Commit

Permalink
fix: tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ArturGaspar committed Jul 9, 2024
1 parent 879243f commit e6ec3be
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 19 deletions.
3 changes: 1 addition & 2 deletions src/components/FilePreview/BaseRenderers/textHooks.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,13 +81,12 @@ describe('Text file preview hooks', () => {
});
});
describe('onError', () => {
it('calls get on the passed url when it changes', async (done) => {
it('calls get on the passed url when it changes', async () => {
axios.get.mockReturnValueOnce(Promise.reject(
{ response: { status: testValue } },
));
await hooks.fetchFile({ ...props, setContent: state.setState.content });
expect(props.onError).toHaveBeenCalledWith(testValue);
done();
});
});
});
Expand Down
26 changes: 9 additions & 17 deletions src/test/app.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ describe('ESG app integration tests', () => {
inspector = new Inspector(el);
});

test('initialization', async (done) => {
test('initialization', async () => {
const verifyInitialState = async () => {
await waitForRequestStatus(RequestKeys.initialize, RequestStates.pending);
const testInitialState = (key) => expect(
Expand Down Expand Up @@ -275,7 +275,6 @@ describe('ESG app integration tests', () => {

await makeTableSelections();
await waitForRequestStatus(RequestKeys.fetchSubmission, RequestStates.pending);
done();
});

describe('initialized', () => {
Expand All @@ -286,7 +285,7 @@ describe('ESG app integration tests', () => {
await waitForRequestStatus(RequestKeys.fetchSubmission, RequestStates.pending);
});

test('initial review state', async (done) => {
test('initial review state', async () => {
// Make table selection and load Review pane
expect(
state.grading.selection,
Expand All @@ -304,10 +303,9 @@ describe('ESG app integration tests', () => {
inspector.review.loadingResponse(),
'Loading Responses pending state text should be displayed in the ReviewModal',
).toBeVisible();
done();
});

test('fetch network error and retry', async (done) => {
test('fetch network error and retry', async () => {
await resolveFns.fetch.networkError();
await waitForRequestStatus(RequestKeys.fetchSubmission, RequestStates.failed);
expect(
Expand All @@ -317,10 +315,9 @@ describe('ESG app integration tests', () => {
// fetch: retry and succeed
await userEvent.click(inspector.review.retryFetchLink());
await waitForRequestStatus(RequestKeys.fetchSubmission, RequestStates.pending);
done()
});

test('fetch success and nav chain', async (done) => {
test('fetch success and nav chain', async () => {
let showRubric = false;
// fetch: success with chained navigation
const verifyFetchSuccess = async (submissionIndex) => {
Expand Down Expand Up @@ -396,7 +393,6 @@ describe('ESG app integration tests', () => {
await userEvent.click(inspector.review.prevNav());
await verifyFetchSuccess(i);
}
done();
});

describe('grading (basic)', () => {
Expand All @@ -416,7 +412,7 @@ describe('ESG app integration tests', () => {
const overallFeedback = 'some overall feedback';

// Set basic grade and feedback
const setGrade = async (done) => {
const setGrade = async () => {
const {
criterionOption,
criterionFeedback,
Expand Down Expand Up @@ -479,26 +475,23 @@ describe('ESG app integration tests', () => {
await resolveFns.lock.success();
}
/*
test('submit pending', async (done) => {
done();
test('submit pending', async () => {
});
test('submit failed', async (done) => {
done();
test('submit failed', async () => {
});
*/
test('grade and submit',
async (done) => {
async () => {
expect(await inspector.find.review.submitGradeBtn()).toBeVisible();
await setGrade();
checkGradingState();
await userEvent.click(inspector.review.rubric.submitGradeBtn());
await resolveFns.updateGrade.success();
checkGradeSuccess();
done();
},
);
test('grade, navigate, and return, maintaining gradingState',
async (done) => {
async () => {
expect(await inspector.find.review.submitGradeBtn()).toBeVisible();
await setGrade();
checkGradingState();
Expand All @@ -507,7 +500,6 @@ describe('ESG app integration tests', () => {
await loadPrev();
await waitForEqual(() => getState().grading.activeIndex, 0, 'activeIndex');
checkGradingState();
done();
},
);
});
Expand Down

0 comments on commit e6ec3be

Please sign in to comment.