Skip to content

Commit

Permalink
fix: export getLatestAuditsForSite (#39)
Browse files Browse the repository at this point in the history
  • Loading branch information
solaris007 authored Dec 7, 2023
1 parent ed93c58 commit e9c9130
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,12 @@
*/

import {
addAudit, getAuditForSite,
addAudit,
getAuditForSite,
getAuditsForSite,
getLatestAuditForSite,
getLatestAudits,
getLatestAuditsForSite,
removeAuditsForSite,
} from './accessPatterns.js';

Expand Down Expand Up @@ -48,6 +50,12 @@ export const auditFunctions = (dynamoClient, config, log) => ({
siteId,
auditType,
),
getLatestAuditsForSite: (siteId) => getLatestAuditsForSite(
dynamoClient,
config,
log,
siteId,
),
addAudit: (auditData) => addAudit(
dynamoClient,
config,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,11 @@ describe('Audit Access Pattern Tests', () => {
expect(exportedFunctions.getLatestAuditForSite).to.be.a('function');
});

it('exports getLatestAuditsForSite function', () => {
expect(exportedFunctions).to.have.property('getLatestAuditsForSite');
expect(exportedFunctions.getLatestAuditsForSite).to.be.a('function');
});

it('exports removeAuditsForSite function', () => {
expect(exportedFunctions).to.have.property('removeAuditsForSite');
expect(exportedFunctions.removeAuditsForSite).to.be.a('function');
Expand Down Expand Up @@ -101,6 +106,12 @@ describe('Audit Access Pattern Tests', () => {
expect(result).to.be.null;
expect(mockDynamoClient.getItem.called).to.be.true;
});

it('calls getLatestAuditsForSite and returns null', async () => {
const result = await exportedFunctions.getLatestAuditsForSite('siteId');
expect(result).to.be.an('array').that.is.empty;
expect(mockDynamoClient.query.called).to.be.true;
});
});

describe('getAuditForSite Tests', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ describe('Data Access Object Tests', () => {
'getAuditsForSite',
'getLatestAudits',
'getLatestAuditForSite',
'getLatestAuditsForSite',
'removeAuditsForSite',
];
const siteFunctions = [
Expand Down

0 comments on commit e9c9130

Please sign in to comment.