tests: Use let and const instead of var

This commit is contained in:
Richard Hansen 2020-09-26 14:38:24 -04:00 committed by John McLear
parent e88c532172
commit 4527254bcc

View file

@ -1,19 +1,18 @@
var assert = require('assert') const assert = require('assert');
supertest = require(__dirname+'/../../../../src/node_modules/supertest'), const supertest = require(__dirname + '/../../../../src/node_modules/supertest');
fs = require('fs'), const fs = require('fs');
settings = require(__dirname + '/../../../../src/node/utils/Settings'), const settings = require(__dirname + '/../../../../src/node/utils/Settings');
api = supertest('http://'+settings.ip+":"+settings.port), const api = supertest(`http://${settings.ip}:${settings.port}`);
path = require('path'); const path = require('path');
var filePath = path.join(__dirname, '../../../../APIKEY.txt'); const filePath = path.join(__dirname, '../../../../APIKEY.txt');
var apiKey = fs.readFileSync(filePath, {encoding: 'utf-8'}); const apiKey = fs.readFileSync(filePath, {encoding: 'utf-8'}).replace(/\n$/, '');
apiKey = apiKey.replace(/\n$/, ""); let apiVersion = 1;
var apiVersion = 1; let groupID = '';
var groupID = ""; let authorID = '';
var authorID = ""; let sessionID = '';
var sessionID = ""; let padID = makeid();
var padID = makeid();
describe('API Versioning', function(){ describe('API Versioning', function(){
it('errors if can not connect', function(done) { it('errors if can not connect', function(done) {
@ -348,16 +347,16 @@ describe('listPadsOfAuthor', function(){
var endPoint = function(point){ const endPoint = function(point) {
return '/api/'+apiVersion+'/'+point+'?apikey='+apiKey; return '/api/'+apiVersion+'/'+point+'?apikey='+apiKey;
} }
function makeid() function makeid()
{ {
var text = ""; let text = '';
var possible = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"; const possible = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
for( var i=0; i < 5; i++ ){ for (let i = 0; i < 5; i++) {
text += possible.charAt(Math.floor(Math.random() * possible.length)); text += possible.charAt(Math.floor(Math.random() * possible.length));
} }
return text; return text;