Skip to content

Commit

Permalink
fix(sites-28856): update shared-data schema to include type in options
Browse files Browse the repository at this point in the history
  • Loading branch information
Ben Helleman committed Feb 6, 2025
1 parent 1c5c511 commit 3dd778e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import {
isInteger,
isIsoDate,
isNonEmptyObject,
isNumber,
isObject,
isValidUrl,
Expand All @@ -41,7 +42,7 @@ const ImportOptionTypeValidator = {
}
},
[ImportJob.ImportOptions.DATA]: (value) => {
if (!isObject(value)) {
if (value && !isNonEmptyObject(value)) {
throw new Error(`Invalid value for ${ImportJob.ImportOptions.DATA}: ${value}`);
}
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,14 @@ describe('ImportJob IT', async () => {
expect(err.cause).to.be.instanceOf(ElectroValidationError);
expect(err.cause.message).to.contain('Invalid value for data: not-an-object');
});

// test to make sure data is not an empty object
data = { ...newJobData, options: { data: { } } };
await ImportJob.create(data).catch((err) => {
expect(err).to.be.instanceOf(DataAccessError);
expect(err.cause).to.be.instanceOf(ElectroValidationError);
expect(err.cause.message).to.contain('Invalid value for data');
});
});

it('throws an error when adding a new import job with invalid options', async () => {
Expand Down

0 comments on commit 3dd778e

Please sign in to comment.