Skip to content

Commit

Permalink
bugfix(api): guard code against invalid values in skill repository
Browse files Browse the repository at this point in the history
  • Loading branch information
laura-bergoens authored Dec 12, 2024
1 parent 8c60df2 commit b8d5e0d
Showing 1 changed file with 42 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -617,6 +617,20 @@ describe('Integration | Repository | skill-repository', function () {
]);
});
});

context('when invalid value given for ids argument', function () {
it('should return an empty array', async function () {
// when
const skills1 = await skillRepository.findOperativeByIds(null);
const skills2 = await skillRepository.findOperativeByIds(undefined);
const skills3 = await skillRepository.findOperativeByIds([]);

// then
expect(skills1).to.deep.equal([]);
expect(skills2).to.deep.equal([]);
expect(skills3).to.deep.equal([]);
});
});
});

describe('#get', function () {
Expand Down Expand Up @@ -761,6 +775,20 @@ describe('Integration | Repository | skill-repository', function () {
]);
});
});

context('when invalid value given for ids argument', function () {
it('should return an empty array', async function () {
// when
const skills1 = await skillRepository.findActiveByRecordIds(null);
const skills2 = await skillRepository.findActiveByRecordIds(undefined);
const skills3 = await skillRepository.findActiveByRecordIds([]);

// then
expect(skills1).to.deep.equal([]);
expect(skills2).to.deep.equal([]);
expect(skills3).to.deep.equal([]);
});
});
});

describe('#findByRecordIds', function () {
Expand Down Expand Up @@ -846,6 +874,20 @@ describe('Integration | Repository | skill-repository', function () {
]);
});
});

context('when invalid value given for ids argument', function () {
it('should return an empty array', async function () {
// when
const skills1 = await skillRepository.findByRecordIds(null);
const skills2 = await skillRepository.findByRecordIds(undefined);
const skills3 = await skillRepository.findByRecordIds([]);

// then
expect(skills1).to.deep.equal([]);
expect(skills2).to.deep.equal([]);
expect(skills3).to.deep.equal([]);
});
});
});
}
});

0 comments on commit b8d5e0d

Please sign in to comment.