From e8aca4fde2c50be165d3950fdbf8d12bad29be50 Mon Sep 17 00:00:00 2001 From: Leangseu Kim Date: Mon, 17 May 2021 16:05:15 -0400 Subject: [PATCH] remove unnecessary testing data update --- src/data/reducers/cohorts.test.js | 32 +++----------- src/data/reducers/grades.test.js | 71 ++++++------------------------- src/data/reducers/tracks.test.js | 42 ++---------------- 3 files changed, 21 insertions(+), 124 deletions(-) diff --git a/src/data/reducers/cohorts.test.js b/src/data/reducers/cohorts.test.js index 0c93aa1..5c09465 100644 --- a/src/data/reducers/cohorts.test.js +++ b/src/data/reducers/cohorts.test.js @@ -3,21 +3,12 @@ import actions from '../actions/cohorts'; const cohortsData = [ { - assignment_type: 'manual', - group_id: null, - id: 1, - name: 'default_group', - user_count: 2, - user_partition_id: null, + arbitraryCohortField: 'some data', }, { - assignment_type: 'auto', - group_id: null, - id: 2, - name: 'auto_group', - user_count: 5, - user_partition_id: null, - }]; + anotherArbitraryCohortField: 'some data', + }, +]; const testingState = { ...initialState, @@ -49,20 +40,7 @@ describe('cohorts reducer', () => { it('set finish fetch to true and error to false then replace results', () => { const newCohortData = [ { - assignment_type: 'manual', - group_id: null, - id: 3, - name: 'default_group', - user_count: 3, - user_partition_id: null, - }, - { - assignment_type: 'auto', - group_id: null, - id: 4, - name: 'auto_group', - user_count: 6, - user_partition_id: null, + newResultFields: 'recieved data', }, ]; const expected = { diff --git a/src/data/reducers/grades.test.js b/src/data/reducers/grades.test.js index d027ec4..e442f01 100644 --- a/src/data/reducers/grades.test.js +++ b/src/data/reducers/grades.test.js @@ -2,64 +2,10 @@ import grades, { initialGradesState as initialState } from './grades'; import actions from '../actions/grades'; import filterActions from '../actions/filters'; -const courseId = 'course-v1:edX+DemoX+Demo_Course'; const headingsData = [ { name: 'exam' }, { name: 'homework2' }, ]; -const gradesData = [ - { - course_id: courseId, - email: 'user1@example.com', - username: 'user1', - user_id: 1, - percent: 0.5, - letter_grade: null, - section_breakdown: [ - { - subsection_name: 'Demo Course Overview', - score_earned: 0, - score_possible: 0, - percent: 0, - displayed_value: '0.00', - grade_description: '(0.00/0.00)', - }, - { - subsection_name: 'Example Week 1: Getting Started', - score_earned: 1, - score_possible: 1, - percent: 1, - displayed_value: '1.00', - grade_description: '(0.00/0.00)', - }, - ], - }, - { - course_id: courseId, - email: 'user22@example.com', - username: 'user22', - user_id: 22, - percent: 0, - letter_grade: null, - section_breakdown: [ - { - subsection_name: 'Demo Course Overview', - score_earned: 0, - score_possible: 0, - percent: 0, - displayed_value: '0.00', - grade_description: '(0.00/0.00)', - }, - { - subsection_name: 'Example Week 1: Getting Started', - score_earned: 1, - score_possible: 1, - percent: 0, - displayed_value: '0.00', - grade_description: '(0.00/0.00)', - }, - ], - }]; const testingState = { ...initialState, @@ -79,24 +25,31 @@ describe('grades reducer', () => { describe('handling actions.received', () => { it('finish fetch then set error and show spinner to false. Add grade data to the results.', () => { + const courseId = 'course-v1:edX+DemoX+Demo_Course'; const expectedPrev = 'testPrevUrl'; const expectedNext = 'testNextUrl'; const expectedTrack = 'verified'; const expectedCohortId = 2; const expectedTotalUsersCount = 4; const expectedFilterUsersCount = 2; + const expectedAssignmentType = 'Homework'; + const gradesData = { + somethingArbitrary: 'some data', + }; const payload = { grades: gradesData, - headings: headingsData, - next: expectedNext, - prev: expectedPrev, - track: expectedTrack, - totalUsersCount: expectedTotalUsersCount, cohort: expectedCohortId, + track: expectedTrack, + assignmentType: expectedAssignmentType, + headings: headingsData, + prev: expectedPrev, + next: expectedNext, courseId, + totalUsersCount: expectedTotalUsersCount, filteredUsersCount: expectedFilterUsersCount, }; + // because of double remapping (action&reducer). It is difficult to reuse expected. const expected = { ...testingState, results: gradesData, diff --git a/src/data/reducers/tracks.test.js b/src/data/reducers/tracks.test.js index 65924bb..959ba55 100644 --- a/src/data/reducers/tracks.test.js +++ b/src/data/reducers/tracks.test.js @@ -3,26 +3,10 @@ import actions from '../actions/tracks'; const tracksData = [ { - slug: 'audit', - name: 'Audit', - min_price: 0, - suggested_prices: '', - currency: 'usd', - expiration_datetime: null, - description: null, - sku: '68EFFFF', - bulk_sku: null, + someArbitraryField: 'arbitrary data', }, { - slug: 'verified', - name: 'Verified Certificate', - min_price: 100, - suggested_prices: '', - currency: 'usd', - expiration_datetime: '2021-05-04T18:08:12.644361Z', - description: null, - sku: '8CF08E5', - bulk_sku: 'A5B6DBE', + anotherArbitraryField: 'more arbitrary data', }]; const testingState = { @@ -54,27 +38,9 @@ describe('tracks reducer', () => { it('replace results then set finish fetching to true and error to false', () => { const newTraksData = [ { - slug: 'audit', - name: 'New Audit', - min_price: 0, - suggested_prices: '', - currency: 'usd', - expiration_datetime: null, - description: null, - sku: '68EFFFF', - bulk_sku: null, + receivedData: 'new data', }, - { - slug: 'verified', - name: 'New Verified Certificate', - min_price: 100, - suggested_prices: '', - currency: 'usd', - expiration_datetime: '2021-05-04T18:08:12.644361Z', - description: null, - sku: '8CF08E5', - bulk_sku: 'A5B6DBE', - }]; + ]; const expected = { ...testingState, results: newTraksData,