IEEE.org     |     IEEE Xplore Digital Library     |     IEEE Standards     |     IEEE Spectrum     |     More Sites

Commit 6a34757b authored by James C. De Ricco's avatar James C. De Ricco
Browse files

assets.controller and .db: fix tests

These tests have been broken since the Display Assets feature
was enhanced with sponsor, project, and asset type filters.

This modifies the tests to use the new type signature
of the assets.db.find function.
parent 07d29b7a
......@@ -28,14 +28,14 @@ describe('assets.controller.find', () => {
it('accesses DB and sends JSON response when no project_id is provided', async () => {
await find(req, res, next);
expect(assetsDb.find).toHaveBeenCalledWith(undefined);
expect(assetsDb.find).toHaveBeenCalledWith(undefined, undefined, undefined);
expect(res.json).toHaveBeenCalledWith(EXPECTED_ASSETS);
});
it('accesses DB and sends JSON response when project_id is provided', async () => {
req.valid['project_id'] = 2;
await find(req, res, next);
expect(assetsDb.find).toHaveBeenCalledWith(2);
expect(assetsDb.find).toHaveBeenCalledWith(undefined, 2, undefined);
expect(res.json).toHaveBeenCalledWith(EXPECTED_ASSETS);
});
......
......@@ -15,18 +15,18 @@ describe('assets.db.find', () => {
it('executes correct DB query when no projectId is specified', async () => {
await find();
await find(undefined, undefined, undefined);
expect(query).toHaveBeenCalledTimes(1);
expect(query.mock.calls[0][0]).toEqual(expect.not.stringContaining('WHERE '));
expect(query.mock.calls[0][0]).toEqual(expect.not.stringContaining('AND project_id '));
});
it('executes correct DB query when projectId is specified', async () => {
await find(1);
await find(undefined, 54, undefined);
expect(query).toHaveBeenCalledTimes(1);
expect(query.mock.calls[0][0]).toEqual(expect.stringContaining('WHERE project_id = $1'));
expect(query.mock.calls[0][1]).toEqual([1]);
expect(query.mock.calls[0][0]).toEqual(expect.stringContaining('AND project_id'));
expect(query.mock.calls[0][1]).toEqual([54]);
});
it('returns an array of asset rows', async () => {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment