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 5, 2024
1 parent 9bfadaf commit 317e17f
Showing 1 changed file with 47 additions and 0 deletions.
47 changes: 47 additions & 0 deletions packages/server/__tests__/lib/grants-collaboration.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,54 @@ 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);
console.log('HELLO', result);
Expand Down

0 comments on commit 317e17f

Please sign in to comment.