Skip to content

Commit

Permalink
testing
Browse files Browse the repository at this point in the history
  • Loading branch information
amyewang committed Aug 4, 2024
1 parent aa7bab9 commit 5139b23
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 18 deletions.
8 changes: 0 additions & 8 deletions packages/server/__tests__/lib/access-helpers.test.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
const { expect } = require('chai');
const sinon = require('sinon');
const { getAdminAuthInfo, isMicrosoftSafeLinksRequest } = require('../../src/lib/access-helpers');
const db = require('../../src/db');
const fixtures = require('../db/seeds/fixtures');

async function expectUnauthorized(request) {
Expand All @@ -13,13 +12,6 @@ async function expectUnauthorized(request) {
}

describe('Acces Helper Module', () => {
before(async () => {
await fixtures.seed(db.knex);
});

after(async () => {
await db.knex.destroy();
});
context('getAdminAuthInfo', () => {
it('throws error if no user ID exists in signed cookie', async () => {
const requestFake = {
Expand Down
23 changes: 14 additions & 9 deletions packages/server/__tests__/lib/grants-collaboration.test.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,9 @@
const { expect } = require('chai');
const db = require('../../src/db');
const knex = require('../../src/db/connection');
const fixtures = require('../db/seeds/fixtures');
const { saveNoteRevision, getOrganizationNotesForGrant } = require('../../src/lib/grantsCollaboration/notes');

describe('db', () => {
before(async () => {
await fixtures.seed(db.knex);
});

after(async () => {
await db.knex.destroy();
});
describe('Grants Collaboration', () => {
context('saveNoteRevision', () => {
it('creates new note', async () => {
const result = await saveNoteRevision(knex, fixtures.grants.earFellowship.grant_id, fixtures.roles.adminRole.id, 'This is a test revision');
Expand Down Expand Up @@ -61,5 +53,18 @@ describe('db', () => {

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);
const expectedNoteStructure = {
notes: [],
pagination: {
from: undefined,
},
};

expect(result).to.deep.equal(expectedNoteStructure);
});
});
});
10 changes: 10 additions & 0 deletions packages/server/__tests__/lib/test-global-setup.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
const db = require('../../src/db');
const fixtures = require('../db/seeds/fixtures');

before(async () => {
await fixtures.seed(db.knex);
});

after(async () => {
await db.knex.destroy();
});
2 changes: 1 addition & 1 deletion packages/server/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
"test:arpa": "NODE_ENV=test __tests__/run_arpa_reporter_tests.sh",
"test:db": "NODE_ENV=test mocha --timeout 10000 __tests__/db/*.test.js",
"test:email": "NODE_ENV=test mocha __tests__/email/*.test.js",
"test:lib": "NODE_ENV=test mocha __tests__/lib/*.test.js",
"test:lib": "NODE_ENV=test mocha --file __tests__/lib/test-global-setup.js __tests__/lib/*.test.js",
"test:scripts": "NODE_ENV=test mocha __tests__/scripts/*.test.js",
"test:userimport": "NODE_ENV=test SUPPRESS_EMAIL=true mocha --exit --bail --require __tests__/api/fixtures.js __tests__/db/userImporter._test_.js",
"test": "yarn test:apis && yarn test:arpa && yarn test:db && yarn test:userimport && yarn test:agencyimport && yarn test:email && yarn test:lib && yarn test:scripts",
Expand Down

0 comments on commit 5139b23

Please sign in to comment.