Skip to content

Commit

Permalink
incremented test coverage for tasks and maps actions
Browse files Browse the repository at this point in the history
  • Loading branch information
offtherailz committed Mar 21, 2017
1 parent 8164e45 commit 237a4cc
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 1 deletion.
34 changes: 33 additions & 1 deletion web/client/actions/__tests__/maps-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,12 @@ var {
SAVE_MAP, saveMap,
DISPLAY_METADATA_EDIT, onDisplayMetadataEdit,
RESET_UPDATING, resetUpdating,
THUMBNAIL_ERROR, thumbnailError
THUMBNAIL_ERROR, thumbnailError,
RESET_CURRENT_MAP, resetCurrentMap,
MAPS_SEARCH_TEXT_CHANGED, mapsSearchTextChanged,
MAPS_LIST_LOAD_ERROR, loadError,
MAP_ERROR, mapError,
MAP_METADATA_UPDATED, mapMetadataUpdated
} = require('../maps');

describe('Test correctness of the maps actions', () => {
Expand Down Expand Up @@ -89,4 +94,31 @@ describe('Test correctness of the maps actions', () => {
expect(retval.resourceId).toBe(resourceId);
expect(retval.map).toBe(map);
});
it('resetCurrentMap', () => {
const a = resetCurrentMap();
expect(a.type).toBe(RESET_CURRENT_MAP);
});
it('mapsSearchTextChanged', () => {
const a = mapsSearchTextChanged("TEXT");
expect(a.type).toBe(MAPS_SEARCH_TEXT_CHANGED);
expect(a.text).toBe("TEXT");
});
it('loadError', () => {
const a = loadError();
expect(a.type).toBe(MAPS_LIST_LOAD_ERROR);
});
it('mapError', () => {
const a = mapError("error");
expect(a.type).toBe(MAP_ERROR);
expect(a.error).toBe("error");
});
it('mapMetadataUpdated', () => {
const a = mapMetadataUpdated("resourceId", "newName", "newDescription", "result", "error");
expect(a.type).toBe(MAP_METADATA_UPDATED);
expect(a.resourceId).toBe("resourceId");
expect(a.newName).toBe("newName");
expect(a.newDescription).toBe("newDescription");
expect(a.result).toBe("result");
expect(a.error).toBe("error");
});
});
19 changes: 19 additions & 0 deletions web/client/actions/__tests__/tasks-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ var {
taskSuccess,
taskStarted,
taskError,
startTask,
TASK_STARTED,
TASK_SUCCESS,
TASK_ERROR
Expand Down Expand Up @@ -49,4 +50,22 @@ describe('Test correctness of the tasks actions', () => {
expect(retVal.type).toBe(TASK_STARTED);
expect(retVal.name).toBe(name);
});

it('startTask', done => {
let started = false;
let executed = false;
let dispatchable = startTask((payload, callback) => {executed = true; expect(payload).toBe("payload"); callback(); }, "payload", "task", "actionPayload");
dispatchable((action) => {
if (action.type === TASK_STARTED) {
expect(action.name).toBe("task");
started = true;
}
if (action.type === TASK_SUCCESS) {
expect(action.actionPayload).toBe("actionPayload");
expect(started).toBe(true);
expect(executed).toBe(true);
done();
}
});
});
});

0 comments on commit 237a4cc

Please sign in to comment.