Skip to content

Commit

Permalink
fix: add validation check for import job id
Browse files Browse the repository at this point in the history
  • Loading branch information
swetabar committed Sep 16, 2024
1 parent 0362ba4 commit 0f974a7
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 11 deletions.
22 changes: 11 additions & 11 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,10 @@ export const createImportUrl = (data) => {
throw new Error(`Invalid Url: ${newState.url}`);
}

if (!hasText(newState.jobId)) {
throw new Error(`Invalid Job ID: ${newState.jobId}`);
}

if (!Object.values(ImportUrlStatus).includes(newState.status)) {
throw new Error(`Invalid Import URL status: ${newState.status}`);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@ describe('ImportUrl Model tests', () => {
it('throws an error if status is invalid', () => {
expect(() => createImportUrl({ ...validImportUrlData, status: 'invalid' })).to.throw('Invalid Import URL status: invalid');
});

it('throws an error if jobId is not a valid string', () => {
expect(() => createImportUrl({ ...validImportUrlData, jobId: null })).to.throw('Invalid Job ID: null');
});
});
describe('Import URL Functionality Tests', () => {
let importUrl;
Expand Down

0 comments on commit 0f974a7

Please sign in to comment.