Skip to content

Commit

Permalink
add some after revision tests
Browse files Browse the repository at this point in the history
  • Loading branch information
amyewang committed Aug 4, 2024
1 parent 6cd4973 commit 79566f1
Showing 1 changed file with 49 additions and 0 deletions.
49 changes: 49 additions & 0 deletions packages/server/__tests__/lib/grants-collaboration.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,55 @@ describe('Grants Collaboration', () => {
expect(result).to.deep.equal(expectedNoteStructure);
});

it('get existing organization notes for grant after a revision', async () => {
const result = await getOrganizationNotesForGrant(knex, fixtures.grants.earFellowship.grant_id, fixtures.agencies.accountancy.tenant_id, { afterRevision: 1 });
const expectedNoteStructure = {
notes: [{
id: 2,
createdAt: result.notes[0].createdAt, // store to pass structure check
text: 'This is a test revision #2',
grant: { id: fixtures.grants.earFellowship.grant_id },
user: {
id: fixtures.roles.adminRole.id,
name: fixtures.users.adminUser.name,
team: {
id: fixtures.agencies.accountancy.id,
name: fixtures.agencies.accountancy.name,
},
organization: {
id: fixtures.tenants.SBA.id,
name: fixtures.tenants.SBA.display_name,
},
},
}],
pagination: {
from: 2,
},
};
// validate createdAt is valid time
expect(result.notes[0].createdAt).to.satisfy((date) => {
const timestamp = new Date(date).getTime();
return !Number.isNaN(timestamp);
});

// remove createdAt to validate the rest of the structure
delete expectedNoteStructure.notes[0].createdAt;
delete result.notes[0].createdAt;

expect(result).to.deep.equal(expectedNoteStructure);
});

it('get no organization notes for grant after a revision', async () => {
const result = await getOrganizationNotesForGrant(knex, fixtures.grants.earFellowship.grant_id, fixtures.agencies.accountancy.tenant_id, { afterRevision: 2 });
const expectedNoteStructure = {
notes: [],
pagination: {
from: 2,
},
};

expect(result).to.deep.equal(expectedNoteStructure);
});
it('get no organization notes for grant', async () => {
const result = await getOrganizationNotesForGrant(knex, fixtures.grants.earFellowship.grant_id, fixtures.agencies.usdr.tenant_id);
const expectedNoteStructure = {
Expand Down

0 comments on commit 79566f1

Please sign in to comment.