Skip to content

Commit

Permalink
feat: introduce fixed URLs in audit type config
Browse files Browse the repository at this point in the history
  • Loading branch information
dzehnder committed Jun 20, 2024
1 parent 11ea319 commit ed6d468
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 4 deletions.
8 changes: 4 additions & 4 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 @@ -15,6 +15,7 @@ const AuditConfigType = (data = {}) => {
disabled: data.disabled || false,
excludedURLs: data.excludedURLs || [],
manualOverwrites: data.manualOverwrites || [],
fixedURLs: data.fixedURLs || [],
};

const self = {
Expand All @@ -27,6 +28,10 @@ const AuditConfigType = (data = {}) => {
updateManualOverwrites: (manualOverwrites) => {
state.manualOverwrites = manualOverwrites;
},
getFixedURLs: () => state.fixedURLs,
updateFixedURLs: (fixedURLs) => {
state.fixedURLs = fixedURLs;
},
updateDisabled: (newValue) => {
state.disabled = newValue;
},
Expand All @@ -40,6 +45,7 @@ AuditConfigType.fromDynamoItem = (dynamoItem) => {
disabled: dynamoItem.disabled,
excludedURLs: dynamoItem.excludedURLs,
manualOverwrites: dynamoItem.manualOverwrites,
fixedURLs: dynamoItem.fixedURLs,
};
return AuditConfigType(auditConfigTypeData);
};
Expand All @@ -48,6 +54,7 @@ AuditConfigType.toDynamoItem = (auditConfigType) => ({
disabled: auditConfigType.disabled(),
excludedURLs: auditConfigType.getExcludedURLs(),
manualOverwrites: auditConfigType.getManualOverwrites(),
fixedURLs: auditConfigType.getFixedURLs(),
});

export default AuditConfigType;
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ export const configSchema = Joi.object({
brokenTargetURL: Joi.string().optional(),
targetURL: Joi.string().optional(),
})).optional(),
fixedURLs: Joi.array().items(Joi.object({
brokenTargetURL: Joi.string().optional(),
targetURL: Joi.string().optional(),
})).optional(),
}).unknown(true),
).unknown(true),
}).unknown(true),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,4 +140,26 @@ describe('AuditConfigType Tests', () => {
expect(auditConfigType.getManualOverwrites()).to.be.an('array').that.is.empty;
});
});

describe('updateFixedURLs Method', () => {
it('updates the updateFixedURLs array', () => {
const auditConfigType = AuditConfigType();
const newFixedURLs = [
{ brokenTargetURL: 'https://broken.co', targetURL: 'https://fixed.co' },
{ brokenTargetURL: 'https://broken.link.co', targetURL: 'https://fixed.link.co' },
];
auditConfigType.updateFixedURLs(newFixedURLs);
expect(auditConfigType.getFixedURLs()).to.eql(newFixedURLs);
});

it('updates the fixedURLs array to an empty array', () => {
const fixedURLs = [
{ brokenTargetURL: 'https://broken.co', targetURL: 'https://fixed.co' },
{ brokenTargetURL: 'https://broken.link.co', targetURL: 'https://fixed.link.co' },
];
const auditConfigType = AuditConfigType({ fixedURLs });
auditConfigType.updateFixedURLs([]);
expect(auditConfigType.getFixedURLs()).to.be.an('array').that.is.empty;
});
});
});

0 comments on commit ed6d468

Please sign in to comment.