Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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