Skip to content

Commit

Permalink
chore(utilities.test.ts): reorganize tests into arrange-act-assert
Browse files Browse the repository at this point in the history
  • Loading branch information
awpala committed Aug 6, 2023
1 parent 40e77d0 commit 6cbc3f2
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions __tests__/utilities.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,32 +43,32 @@ describe('frontend utilities tests', () => {
});

it('maps payload to array, ascending by sortKey', () => {
const mappedArray = mapPayloadToArray(inputPayload, 'sortKeyField');
const expectedOutput = [
{ sortKeyField: 1, courseId: 'CS-6150' },
{ sortKeyField: 2, courseId: 'CS-6200' },
{ sortKeyField: 3, courseId: 'CS-6035' },
];
const mappedArray = mapPayloadToArray(inputPayload, 'sortKeyField');
expect(mappedArray).toMatchObject(expectedOutput);
});

it('maps payload to array, descending by sortKey', () => {
const mappedArray = mapPayloadToArray(inputPayload, 'courseID', DESC);
const expectedOutput = [
{ sortKeyField: 2, courseId: 'CS-6200' },
{ sortKeyField: 1, courseId: 'CS-6150' },
{ sortKeyField: 3, courseId: 'CS-6035' },
];
const mappedArray = mapPayloadToArray(inputPayload, 'courseID', DESC);
expect(mappedArray).toMatchObject(expectedOutput);
});

it('falls through in original order if no sortKey specified', () => {
const mappedArray = mapPayloadToArray(inputPayload);
const expectedOutput = [
{ sortKeyField: 3, courseId: 'CS-6035' },
{ sortKeyField: 1, courseId: 'CS-6150' },
{ sortKeyField: 2, courseId: 'CS-6200' },
];
const mappedArray = mapPayloadToArray(inputPayload);
expect(mappedArray).toMatchObject(expectedOutput);
});
});
Expand Down

0 comments on commit 6cbc3f2

Please sign in to comment.