Skip to content

Commit

Permalink
test: address tests
Browse files Browse the repository at this point in the history
  • Loading branch information
MichaelTaylor3D committed Dec 11, 2023
1 parent 86e073a commit 9a996c2
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 10 deletions.
17 changes: 14 additions & 3 deletions tests/resources/projects.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,9 @@ describe('Project Resource CRUD', function () {
describe('error states', function () {
it('errors if there if there is no connection to the datalayer', async function () {
sinon.stub(datalayer, 'dataLayerAvailable').resolves(false);
const response = await supertest(app).get('/v1/projects');
const response = await supertest(app)
.get('/v1/projects')
.query({ page: 1, limit: 100 });
expect(response.statusCode).to.equal(400);

expect(response.body.error).to.equal(
Expand All @@ -55,14 +57,19 @@ describe('Project Resource CRUD', function () {
describe('success states', function () {
it('gets all the projects available', async function () {
// no query params
const projects = await testFixtures.getProjectByQuery();
const projects = await testFixtures.getProjectByQuery({
page: 1,
limit: 100,
});
expect(projects.length).to.equal(12);
}).timeout(TEST_WAIT_TIME * 10);

it('gets all the projects filtered by orgUid', async function () {
// ?orgUid=XXXX
const projects = await testFixtures.getProjectByQuery({
orgUid: 'a807e453-6524-49df-a32d-785e56cf560e',
page: 1,
limit: 100,
});
expect(projects.length).to.equal(3);
}).timeout(TEST_WAIT_TIME * 10);
Expand All @@ -71,6 +78,8 @@ describe('Project Resource CRUD', function () {
// ?search=XXXX
const projects = await testFixtures.getProjectByQuery({
search: 'City of Arcata',
page: 1,
limit: 100,
});
expect(projects.length).to.equal(1);
}).timeout(TEST_WAIT_TIME * 10);
Expand All @@ -80,6 +89,8 @@ describe('Project Resource CRUD', function () {
const projects = await testFixtures.getProjectByQuery({
orgUid: 'a807e453-6524-49df-a32d-785e56cf560e',
search: 'City of Arcata',
page: 1,
limit: 100,
});

expect(projects.length).to.equal(1);
Expand Down Expand Up @@ -222,7 +233,7 @@ describe('Project Resource CRUD', function () {
describe('error states', function () {
it('errors if no home organization exists', async function () {
const responseCreate = await supertest(app)
.get('/v1/projects')
.post('/v1/projects')
.send({
...newProject,
});
Expand Down
27 changes: 20 additions & 7 deletions tests/resources/units.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,9 @@ describe('Units Resource CRUD', function () {
await testFixtures.createNewUnit();
await testFixtures.commitStagingRecords();
await testFixtures.waitForDataLayerSync();
const result = await supertest(app).get('/v1/units');
const result = await supertest(app)
.get('/v1/units')
.query({ page: 1, limit: 100 });
response = result.body[0];
});

Expand All @@ -44,15 +46,17 @@ describe('Units Resource CRUD', function () {

it('gets all the units available', async function () {
// no query params
const result = await supertest(app).get('/v1/units').query({});
const result = await supertest(app)
.get('/v1/units')
.query({ page: 1, limit: 100 });

expect(result.body.length).to.not.equal(0);
}).timeout(TEST_WAIT_TIME * 10);

it('gets all the units filtered by orgUid', async function () {
const result = await supertest(app)
.get('/v1/units')
.query({ orgUid: response.orgUid });
.query({ orgUid: response.orgUid, page: 1, limit: 100 });

expect(result.body.length).to.not.equal(1);
// ?orgUid=XXXX
Expand All @@ -73,7 +77,7 @@ describe('Units Resource CRUD', function () {

const result = await supertest(app)
.get('/v1/units')
.query({ order: 'SERIALNUMBER' });
.query({ order: 'SERIALNUMBER', page: 1, limit: 100 });

expect(result.body[0].serialNumberBlock).to.equal('AAAAA1-AAAAA2');
expect(result.body[1].serialNumberBlock).to.equal('AAAAA11-AAAAA21');
Expand All @@ -86,15 +90,20 @@ describe('Units Resource CRUD', function () {
// ?search=XXXX
const result = await supertest(app)
.get('/v1/units')
.query({ search: 'Certification' });
.query({ search: 'Certification', page: 1, limit: 100 });

expect(result.body.length).to.not.equal(1);
}).timeout(TEST_WAIT_TIME * 10);
it('gets all the units for a search term filtered by orgUid', async function () {
// ?orgUid=XXXX&search=XXXX
const result = await supertest(app)
.get('/v1/units')
.query({ orgUid: response.orgUid, search: 'Certification' });
.query({
orgUid: response.orgUid,
search: 'Certification',
page: 1,
limit: 100,
});

expect(result.body.length).to.not.equal(1);
}).timeout(TEST_WAIT_TIME * 10);
Expand All @@ -110,7 +119,11 @@ describe('Units Resource CRUD', function () {
// ?warehouseUnitId=XXXX
const result = await supertest(app)
.get('/v1/units')
.query({ warehouseUnitId: response.warehouseUnitId, limit: 1 });
.query({
warehouseUnitId: response.warehouseUnitId,
page: 1,
limit: 100,
});

expect(result.body.length).to.not.equal(1);
}).timeout(TEST_WAIT_TIME * 10);
Expand Down

0 comments on commit 9a996c2

Please sign in to comment.