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

Commit 393d962e authored by APalumbo97's avatar APalumbo97
Browse files

Merge branch 'dev' into export-headers

parents 27f8ffb1 7f0de63a
......@@ -85,14 +85,14 @@ describe('GET assetTypes', () => {
.get('/api/v1/assetTypes')
.expect(200)
.then((res) => {
expect(res.body).toEqual(
expect(res.body.rows).toEqual(
expect.arrayContaining([
expect.objectContaining(EXPECTED_ASSET_TYPE1),
expect.objectContaining(EXPECTED_ASSET_TYPE2),
expect.objectContaining(EXPECTED_ASSET_TYPE3)
])
);
expect(res.body).toHaveLength(3);
expect(res.body.rows).toHaveLength(3);
});
});
});
......
const { findAssetTypes } = require('../assetDefinitions.controller');
const { getAssetTypes } = require('../assetDefinitions.controller');
const assetDefinitionsDb = require('../../db/assetDefinitions.db');
describe('assetDefinitions.controller.getAssetTypes', () => {
......@@ -22,8 +22,8 @@ describe('assetDefinitions.controller.getAssetTypes', () => {
});
it('returns all asset types in DB', async () => {
await findAssetTypes(req, res, next);
expect(res.json).toHaveBeenCalledWith(expectedAssetTypes);
await getAssetTypes(req, res, next);
expect(res.json).toHaveBeenCalledWith(data);
});
});
......
......@@ -14,7 +14,10 @@ FROM
JOIN project ON asset.project_id = project.id
JOIN sponsor ON project.sponsor_id = sponsor.id
JOIN asset_type ON asset.asset_type_id = asset_type.id
`;
WHERE
TRUE
`; // The WHERE TRUE is needed for the find function to append WHERE clauses properly
/**
* Find project assets.
......@@ -142,4 +145,3 @@ module.exports = {
find,
create
};
......@@ -16,7 +16,7 @@ const QUERY_FIND = `
project
WHERE
TRUE
`;
`; // The WHERE TRUE is needed for the find function to append WHERE clauses properly
// A query to create a new project in the database
const QUERY_CREATE = `
......
......@@ -15,7 +15,7 @@ describe('assetDefinitions.findAssetTypes', () => {
});
it('finds all asset types stored in the DB', async () => {
const assetTypes = await assetDefinitions.findAssetTypes();
const assetTypes = await assetDefinitions.fetchAssetTypes();
expect(fetch.mock.calls[0][0]).toBe(URL);
expect(assetTypes).toEqual(EXPECTED_ASSET_TYPES);
});
......@@ -42,4 +42,4 @@ describe('assetDefinitions.sendCSV', () => {
expect(fetch.mock.calls[0][0]).toBe(URL);
expect(response).toEqual(EXPECTED_RESPONSE);
});
});
\ No newline at end of file
});
......@@ -27,6 +27,16 @@ const post = (url, data) => {
}).then(handleFetchErrors);
};
const put = (url, data) => {
return fetch(url, {
method: 'PUT',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify(data)
}).then(handleFetchErrors);
};
const putCSV = (url, assetTypeId, csvFile) => {
// Key-value pairs that represent form fields and corresponding values
const formData = new FormData();
......@@ -43,5 +53,6 @@ export default {
URL,
get,
post,
put,
putCSV
};
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