-
Notifications
You must be signed in to change notification settings - Fork 479
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #16385 from code-dot-org/import-google-classroom-next
Call API to import a Google Classroom on "Import Section" click
- Loading branch information
Showing
14 changed files
with
141 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
70 changes: 70 additions & 0 deletions
70
apps/test/unit/templates/teacherDashboard/googleClassroomReduxTest.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
import { assert } from '../../../util/configuredChai'; | ||
import sinon from 'sinon'; | ||
import configureStore from 'redux-mock-store'; | ||
import thunk from 'redux-thunk'; | ||
|
||
import reducer, { | ||
loadClassroomList, | ||
setClassroomList, | ||
failedLoad, | ||
importClassroomStarted, | ||
} from '@cdo/apps/templates/teacherDashboard/googleClassroomRedux'; | ||
|
||
describe('googleClassroomRedux', () => { | ||
const initialState = reducer(undefined, {}); | ||
|
||
describe('loadClassroomList', () => { | ||
it('loads the classroom list from the API', finish => { | ||
const data = { | ||
courses: [{id: "6949959535", section: "123", name: "Sample class", enrollment_code: "gc12wb"}] | ||
}; | ||
|
||
const xhr = sinon.useFakeXMLHttpRequest(); | ||
xhr.onCreate = request => { | ||
setTimeout(() => { | ||
const mockResponse = JSON.stringify(data); | ||
request.respond(200, {'Content-Type': 'application/json'}, mockResponse); | ||
|
||
assert.deepEqual([setClassroomList(data.courses)], store.getActions()); | ||
finish(); | ||
}, 0); | ||
}; | ||
|
||
const mockStore = configureStore([thunk]); | ||
const store = mockStore({}); | ||
|
||
store.dispatch(loadClassroomList()); | ||
}); | ||
|
||
it('fails to load the classroom list from the API', finish => { | ||
const failureStatus = 403; | ||
const failureMessage = 'Sample error message'; | ||
|
||
const xhr = sinon.useFakeXMLHttpRequest(); | ||
xhr.onCreate = request => { | ||
setTimeout(() => { | ||
const mockResponse = JSON.stringify({error: failureMessage}); | ||
request.respond(failureStatus, {'Content-Type': 'application/json'}, mockResponse); | ||
|
||
assert.deepEqual([failedLoad(failureStatus, failureMessage)], store.getActions()); | ||
finish(); | ||
}, 0); | ||
}; | ||
|
||
const mockStore = configureStore([thunk]); | ||
const store = mockStore({}); | ||
|
||
store.dispatch(loadClassroomList()); | ||
}); | ||
}); | ||
|
||
describe('importClassroomStarted', () => { | ||
it('starting import sets the list of classrooms to null', () => { | ||
const state = reducer(initialState, setClassroomList(['fake classrooms'])); | ||
assert.deepEqual(state.classrooms, ['fake classrooms']); | ||
|
||
const nextState = reducer(state, importClassroomStarted()); | ||
assert.equal(nextState.classrooms, null); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters