trc-client-core
Version:
The core of the TRC Client
37 lines (30 loc) • 1.19 kB
JavaScript
import tape from 'tape';
import sinon from 'sinon';
import xhr from 'trc-client-core/src/utils/xhr';
import SurveyActions from 'trc-client-core/src/report/SurveyActions';
import {
SURVEY_NOTIFICATIONS,
SURVEY_POSSIBLE_COURSES,
SURVEY_CODES
} from 'trc-client-core/src/constants/Endpoints';
var TEST_QUERY = 'TEST_QUERY';
var get = sinon.stub(xhr, 'get', () => Promise.resolve());
tape('SurveyActions.getNotificationList', test => {
test.plan(1);
SurveyActions.getNotificationList(TEST_QUERY).then(() => {
test.ok(get.calledWith(SURVEY_NOTIFICATIONS, TEST_QUERY), 'queries the correct endpoint for getNotificationList');
});
});
tape('SurveyActions.getPossibleCourses', test => {
test.plan(1);
SurveyActions.getPossibleCourses(TEST_QUERY).then(() => {
test.ok(get.calledWith(SURVEY_POSSIBLE_COURSES), 'queries the correct endpoint for getPossibleCourses')
});
});
tape('SurveyActions.getSurveyCodes', test => {
test.plan(1);
SurveyActions.getSurveyCodes(TEST_QUERY).then(() => {
test.ok(get.calledWith(SURVEY_CODES), 'queries the correct endpoint for getSurveyCodes');
});
});
tape.onFinish(xhr.get.restore);