Skip to content

Commit

Permalink
feat: add test for handle save screen
Browse files Browse the repository at this point in the history
  • Loading branch information
Lan Le committed Apr 1, 2024
1 parent 299ee83 commit d2ffacd
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
2 changes: 1 addition & 1 deletion app/packs/src/utilities/ElementUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -480,7 +480,7 @@ const handleSaveDataset = (element, uiStoreState, callbackFunc, ...args) => {
const { elementID, isSaving, elementType } = containerDataSet;
if (!isSaving) return false;

const supporedTypes = ['sample', 'reaction', 'researchPlan', 'wellplate']
const supporedTypes = ['sample', 'reaction', 'researchPlan', 'wellplate', 'screen'];
if (supporedTypes.includes(elementType)) {
if (Array.isArray(element)) {
if (elementType === 'sample') {
Expand Down
20 changes: 19 additions & 1 deletion spec/javascripts/utils/ElementUtils.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,7 @@ describe('Handle container dataset saving', () => {
});

describe('save dataset for wellplate', () => {
it('when it is not the same wellplate plan id', () => {
it('when it is not the same wellplate id', () => {
const wellplate = { id: 100 };
const containerDataSet = { elementType: 'wellplate', isSaving: true, elementID: 101 };
const uiState = { containerDataSet };
Expand All @@ -335,4 +335,22 @@ describe('Handle container dataset saving', () => {
expect(triggered).toEqual(true);
});
});

describe('save dataset for screen', () => {
it('when it is not the same screen id', () => {
const screen = { id: 100 };
const containerDataSet = { elementType: 'screen', isSaving: true, elementID: 101 };
const uiState = { containerDataSet };
const triggered = handleSaveDataset(screen, uiState, handleSubmit);
expect(triggered).toEqual(false);
});

it('when it is the same screen id', () => {
const screen = { id: 100 };
const containerDataSet = { elementType: 'screen', isSaving: true, elementID: 100 };
const uiState = { containerDataSet };
const triggered = handleSaveDataset(screen, uiState, handleSubmit, true);
expect(triggered).toEqual(true);
});
});
});

0 comments on commit d2ffacd

Please sign in to comment.