Skip to content

Commit

Permalink
test: adjust tests
Browse files Browse the repository at this point in the history
  • Loading branch information
iuliag committed Jan 26, 2024
1 parent 2a28022 commit 1697008
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,11 @@ const AUDIT_TYPE_DISABLED_DEFAULTS = {
};

function getAuditTypeConfigs(auditTypeConfigs, auditsDisabled) {
if (!auditTypeConfigs || Object.keys(auditTypeConfigs).length === 0) {
return {
[AUDIT_TYPE_BROKEN_BACKLINKS]: AuditConfigType({ disabled: true }),
};
}
return Object.entries(auditTypeConfigs || {}).reduce((acc, [key, value]) => {
const disabled = value.disabled !== undefined
? value.disabled : (AUDIT_TYPE_DISABLED_DEFAULTS[key] || auditsDisabled || false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,16 @@
import { expect } from 'chai';

import AuditConfig from '../../../../src/models/site/audit-config.js';
import { AUDIT_TYPE_BROKEN_BACKLINKS } from '../../../../src/models/audit.js';

describe('AuditConfig Tests', () => {
describe('AuditConfig Creation', () => {
it('creates an AuditConfig with defaults when no data is provided', () => {
const auditConfig = AuditConfig();
expect(auditConfig.auditsDisabled()).to.be.false;
expect(auditConfig.getAuditTypeConfigs()).to.be.empty;
const auditTypeConfigs = auditConfig.getAuditTypeConfigs();
expect(auditTypeConfigs[AUDIT_TYPE_BROKEN_BACKLINKS]).to.be.an('object');
expect(auditTypeConfigs[AUDIT_TYPE_BROKEN_BACKLINKS].disabled()).to.be.true;
});

it('creates an AuditConfig with provided data', () => {
Expand Down Expand Up @@ -75,15 +78,6 @@ describe('AuditConfig Tests', () => {
const typeConfigs = auditConfig.getAuditTypeConfigs();
expect(typeConfigs).to.have.keys(['type1', 'type2']);
});

it('returns no audit type configurations', () => {
const data = {
auditTypeConfigs: {},
};
const auditConfig = AuditConfig(data);
const typeConfigs = auditConfig.getAuditTypeConfigs();
expect(typeConfigs).to.be.an('object').that.is.empty;
});
});

describe('updateAuditsDisabled Method', () => {
Expand Down

0 comments on commit 1697008

Please sign in to comment.