trc-client-core
Version:
The core of the TRC Client
64 lines (53 loc) • 2.42 kB
JavaScript
// import {FakeRefluxStore} from 'trc-client-core/src/utils/TestUtils';
import SurveyStore from 'trc-client-core/src/report/SurveyStore';
describe('SurveyStore', () => {
const EXPECTED = 'TEST_VALUE';
beforeEach(() => {
SurveyStore.init();
});
describe('init', () => {
it('set sets the inital null states', () => {
SurveyStore.init();
expect(SurveyStore.get('notificationsList').size).toBe(0);
expect(SurveyStore.get('possibleCourses').size).toBe(0);
expect(SurveyStore.get('surveyCodes').size).toBe(0);
expect(SurveyStore.get('notificationsListLoading')).toBe(false);
});
});
describe('mapToSelectShape', () => {
it('returns a key/label pair object from an string', () => {
expect(SurveyStore.mapToSelectShape('test')).toEqual({label: 'test', value: 'test'});
});
});
describe('onGetNotificationList', () => {
it('sets loading state to true', () => {
SurveyStore.onGetNotificationList()
expect(SurveyStore.get('notificationsListLoading')).toBe(true);
});
});
describe('onGetNotificationListCompleted', () => {
it('sets loading state to false & sets notificationsList to the returned data', () => {
SurveyStore.onGetNotificationListCompleted(EXPECTED);
expect(SurveyStore.get('notificationsListLoading')).toBe(false);
expect(SurveyStore.get('notificationsList')).toBe(EXPECTED);
});
});
describe('onGetPossibleCoursesCompleted', () => {
it('sets possibleCourses to a collection of mapToSelectShape with a preprended empty value', () => {
SurveyStore.onGetPossibleCoursesCompleted([EXPECTED]);
expect(SurveyStore.get('possibleCourses').toJS()).toEqual([
{label: 'All Courses', value: undefined},
{label: EXPECTED, value: EXPECTED}
]);
});
});
describe('onGetSurveyCodesCompleted', () => {
it('sets surveyCodes to a collection of mapToSelectShape with a preprended empty value', () => {
SurveyStore.onGetSurveyCodesCompleted([EXPECTED]);
expect(SurveyStore.get('surveyCodes').toJS()).toEqual([
{label: 'All Id\'s', value: undefined},
{label: EXPECTED, value: EXPECTED}
]);
});
});
});