tests: Include the filename in the test output

Also some minor consistency cleanups.
This commit is contained in:
Richard Hansen 2020-10-09 18:19:46 -04:00 committed by John McLear
parent 50e402193b
commit 3e14016214
13 changed files with 2296 additions and 2276 deletions

View file

@ -11,34 +11,36 @@ const api = supertest('http://'+settings.ip+":"+settings.port);
const apiKey = common.apiKey;
var apiVersion = '1.2.14';
describe('Connectivity for instance-level API tests', function() {
it('can connect', function(done) {
api.get('/api/')
.expect('Content-Type', /json/)
.expect(200, done)
describe(__filename, function() {
describe('Connectivity for instance-level API tests', function() {
it('can connect', function(done) {
api.get('/api/')
.expect('Content-Type', /json/)
.expect(200, done)
});
});
});
describe('getStats', function(){
it('Gets the stats of a running instance', function(done) {
api.get(endPoint('getStats'))
.expect(function(res){
if (res.body.code !== 0) throw new Error("getStats() failed");
describe('getStats', function() {
it('Gets the stats of a running instance', function(done) {
api.get(endPoint('getStats'))
.expect(function(res) {
if (res.body.code !== 0) throw new Error("getStats() failed");
if (!(('totalPads' in res.body.data) && (typeof res.body.data.totalPads === 'number'))) {
throw new Error(`Response to getStats() does not contain field totalPads, or it's not a number: ${JSON.stringify(res.body.data)}`);
}
if (!(('totalPads' in res.body.data) && (typeof res.body.data.totalPads === 'number'))) {
throw new Error(`Response to getStats() does not contain field totalPads, or it's not a number: ${JSON.stringify(res.body.data)}`);
}
if (!(('totalSessions' in res.body.data) && (typeof res.body.data.totalSessions === 'number'))) {
throw new Error(`Response to getStats() does not contain field totalSessions, or it's not a number: ${JSON.stringify(res.body.data)}`);
}
if (!(('totalSessions' in res.body.data) && (typeof res.body.data.totalSessions === 'number'))) {
throw new Error(`Response to getStats() does not contain field totalSessions, or it's not a number: ${JSON.stringify(res.body.data)}`);
}
if (!(('totalActivePads' in res.body.data) && (typeof res.body.data.totalActivePads === 'number'))) {
throw new Error(`Response to getStats() does not contain field totalActivePads, or it's not a number: ${JSON.stringify(res.body.data)}`);
}
})
.expect('Content-Type', /json/)
.expect(200, done);
if (!(('totalActivePads' in res.body.data) && (typeof res.body.data.totalActivePads === 'number'))) {
throw new Error(`Response to getStats() does not contain field totalActivePads, or it's not a number: ${JSON.stringify(res.body.data)}`);
}
})
.expect('Content-Type', /json/)
.expect(200, done);
});
});
});