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

Unverified Commit 6647e255 authored by tilley14's avatar tilley14 Committed by GitHub
Browse files

Merge pull request #86 from my-conservation-life/fixing-some-tests

Fixing some tests
parents f70ee487 9b4a646d
......@@ -80,8 +80,8 @@ describe('GET assetTypes', () => {
await teardown();
});
it('gets all asset types', () => {
return request(app)
it('gets all asset types', async () => {
await request(app)
.get('/api/v1/assetTypes')
.expect(200)
.then((res) => {
......@@ -110,9 +110,10 @@ describe('POST assetPropTypes', () => {
await teardown();
});
it('gets all asset property types', () => {
return request(app)
it('gets all asset property types', async () => {
await request(app)
.post('/api/v1/assetPropTypes')
.send({'assetTypeID' : '1'})
.expect(200)
.then((res) => {
expect(res.body.rows).toEqual(
......@@ -122,7 +123,7 @@ describe('POST assetPropTypes', () => {
expect.objectContaining(EXPECTED_ASSET_TYPE3)
])
);
expect(res.body.rows).toHaveLength(3);
expect(res.body.rows).toHaveLength(1);
});
});
});
......@@ -140,9 +141,10 @@ describe('POST assetPropsByTypeID', () => {
await teardown();
});
it('gets all asset property types', () => {
return request(app)
it('gets all asset property types', async () => {
await request(app)
.post('/api/v1/assetPropsByTypeID')
.send({'assetTypeID' : '1'})
.expect(200)
.then((res) => {
expect(res.body.rows).toEqual(
......
......@@ -35,11 +35,7 @@ describe('assetDefinitions.controller.getAssetPropsByTypeID', () => {
let data;
beforeEach(() => {
req = {
'body': {
}
};
req = { valid : { assetTypeID: 1 } };
res = {
json: jest.fn()
......@@ -65,7 +61,7 @@ describe('assetDefinitions.controller.getAssetPropsTypes', () => {
let data;
beforeEach(() => {
req = {};
req = { valid : { assetTypeID: 1 } };
res = {
json: jest.fn()
......
......@@ -184,7 +184,6 @@ describe('assetDefinitions.db.storeCSV', () => {
it('finds all asset types in the database', async () => {
const actualRows = await findAssetTypes();
expect(actualRows).toEqual(rows);
expect(query).toHaveBeenCalledWith(expect.stringContaining('asset_type'));
});
});
......@@ -203,7 +202,7 @@ describe('assetDefinitions.db.storeCSV', () => {
it('finds all properties associated with the asset type ID given', async () => {
const actualRows = await findAssetPropTypes(assetTypeId);
expect(actualRows).toEqual(rows);
expect(actualRows.rows).toEqual(rows);
});
});
......
......@@ -345,36 +345,6 @@ const parseLongitude = (lonStr) => {
ParseResult.failure('Longitudes must be numbers between -180 and 180');
};
/**
* Parse a latitude value from a string
*
* @param {string} latStr - A string that is parsable into a floating point number
* @returns {ParseResult} - Parse success with a float value that is a latitude, or a failure message
*/
const parseLatitude = (latStr) => {
const lat = parseFloat(latStr);
const isValid = (!isNaN(lat) && validLatitude(lat));
return isValid ?
ParseResult.success(lat) :
ParseResult.failure('Latitudes must be numbers between -90 and 90');
};
/**
* Parse a longitude value from a string
*
* @param {string} lonStr - A string that is parsable into a floating point number
* @returns {ParseResult} - Parse success with a float value that is a longitude, or a failure message
*/
const parseLongitude = (lonStr) => {
const lon = parseFloat(lonStr);
const isValid = (!isNaN(lon) && validLongitude(lon));
return isValid ?
ParseResult.success(lon) :
ParseResult.failure('Longitudes must be numbers between -180 and 180');
};
/**
* Validates if it is a string and within min/max length
*
......
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