Skip to content

Commit

Permalink
test
Browse files Browse the repository at this point in the history
  • Loading branch information
RobAndrewHurst committed Jan 20, 2025
1 parent 194fe26 commit 785c44c
Showing 1 changed file with 74 additions and 47 deletions.
121 changes: 74 additions & 47 deletions tests/mod/query.test.mjs
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',
);
},
);
});
}

0 comments on commit 785c44c

Please sign in to comment.