-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
194fe26
commit 785c44c
Showing
1 changed file
with
74 additions
and
47 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,57 +1,84 @@ | ||
|
||
/** | ||
* ## queryTest() | ||
* @module mod/query | ||
*/ | ||
|
||
/** | ||
* This function is used to test the query API endpoint | ||
* @function querytest | ||
* @param {Object} mapview | ||
*/ | ||
* @function querytest | ||
* @param {Object} mapview | ||
*/ | ||
export async function queryTest() { | ||
await codi.describe('Query: Testing Query API', async () => { | ||
/** | ||
* @description Query: Testing Query defined on infoj entry | ||
* @function it | ||
*/ | ||
await codi.it('Query: Testing Query defined on infoj entry', async () => { | ||
const expected_result = [1, 2, 5, 3, 4]; | ||
const results = await mapp.utils.xhr( | ||
`/test/api/query?template=data_array`, | ||
); | ||
codi.assertEqual( | ||
results, | ||
expected_result, | ||
'We should be able to just call the template even if its not part of the workspace.templates object in configuration', | ||
); | ||
}); | ||
/** | ||
* @description Query: Testing Module defined in templates | ||
* @function it | ||
*/ | ||
await codi.it('Query: Testing Module defined in templates', async () => { | ||
const expected_result = { | ||
bar: 'foo', | ||
}; | ||
const results = await mapp.utils.xhr( | ||
`/test/api/query?template=module_test`, | ||
); | ||
codi.assertEqual( | ||
results, | ||
expected_result, | ||
'The Module should return the basic query', | ||
); | ||
}); | ||
|
||
await codi.describe('Query: Testing Query API', async () => { | ||
/** | ||
* @description Query: Testing Query defined on infoj entry | ||
* @function it | ||
*/ | ||
await codi.it('Query: Testing Query defined on infoj entry', async () => { | ||
const expected_result = [1, 2, 5, 3, 4]; | ||
const results = await mapp.utils.xhr(`/test/api/query?template=data_array`); | ||
codi.assertEqual(results, expected_result, 'We should be able to just call the template even if its not part of the workspace.templates object in configuration'); | ||
}); | ||
/** | ||
* @description Query: Testing Module defined in templates | ||
* @function it | ||
*/ | ||
await codi.it('Query: Testing Module defined in templates', async () => { | ||
const expected_result = { | ||
'bar': 'foo' | ||
} | ||
const results = await mapp.utils.xhr(`/test/api/query?template=module_test`); | ||
codi.assertEqual(results, expected_result, 'The Module should return the basic query'); | ||
}); | ||
|
||
/** | ||
* @description Query: Testing a query with a bogus dbs string via the req params | ||
* @function it | ||
*/ | ||
await codi.it('Query: Testing a query with a bogus dbs string via the req params', async () => { | ||
const expected_result = { | ||
'bar': 'foo' | ||
} | ||
const results = await mapp.utils.xhr(`/test/api/query?template=module_test&dbs=bogus`); | ||
codi.assertEqual(results, expected_result, 'The Module should return the basic query'); | ||
}); | ||
/** | ||
* @description Query: Testing a query with a bogus dbs string via the req params | ||
* @function it | ||
*/ | ||
await codi.it( | ||
'Query: Testing a query with a bogus dbs string via the req params', | ||
async () => { | ||
const expected_result = { | ||
bar: 'foo', | ||
}; | ||
const results = await mapp.utils.xhr( | ||
`/test/api/query?template=module_test&dbs=bogus`, | ||
); | ||
codi.assertEqual( | ||
results, | ||
expected_result, | ||
'The Module should return the basic query', | ||
); | ||
}, | ||
); | ||
|
||
/** | ||
* @description Query: Testing a query with a bogus dbs on the template | ||
* @function it | ||
*/ | ||
await codi.it('Query: Testing a query with a bogus dbs on the template', async () => { | ||
const results = await mapp.utils.xhr(`/test/api/query?template=bogus_data_array`); | ||
codi.assertTrue(results instanceof Error, 'We should return an error for a bogus DBS connection'); | ||
}); | ||
}); | ||
} | ||
/** | ||
* @description Query: Testing a query with a bogus dbs on the template | ||
* @function it | ||
*/ | ||
await codi.it( | ||
'Query: Testing a query with a bogus dbs on the template', | ||
async () => { | ||
const results = await mapp.utils.xhr( | ||
`/test/api/query?template=bogus_data_array`, | ||
); | ||
codi.assertTrue( | ||
results instanceof Error, | ||
'We should return an error for a bogus DBS connection', | ||
); | ||
}, | ||
); | ||
}); | ||
} |