diff --git a/package.json b/package.json index 065aacccc..e619e373a 100644 --- a/package.json +++ b/package.json @@ -8,7 +8,7 @@ "test": "npm run-script eslint && npm run-script jsonlint && npm run-script mocha-suite", "eslint": "node_modules/.bin/eslint --ext .ts,.js --max-warnings 0 src", "jsonlint": "find . -not -path './node_modules/*' -type f -name '*.json' -o -type f -name '*.json.example' | while read json; do echo $json ; jq . $json; done", - "mocha-suite": "NODE_ENV=test CMD_DB_URL=\"sqlite::memory:\" mocha --exit", + "mocha-suite": "tsc && NODE_ENV=test CMD_DB_URL=\"sqlite::memory:\" mocha --exit built/test/*.js", "standard": "echo 'standard is no longer being used, use `npm run eslint` instead!' && exit 1", "dev": "webpack --config webpack.dev.js --progress --colors --watch", "heroku-prebuild": "bin/heroku", @@ -175,6 +175,7 @@ "@types/helmet": "^0.0.45", "@types/lodash": "^4.14.149", "@types/minio": "^7.0.5", + "@types/mocha": "^7.0.2", "@types/node": "^13.11.1", "@types/passport": "^1.0.3", "@types/passport-facebook": "^2.1.9", diff --git a/src/test/csp.js b/src/test/csp.ts similarity index 92% rename from src/test/csp.js rename to src/test/csp.ts index 8cf24b9a7..80d7a58ab 100644 --- a/src/test/csp.js +++ b/src/test/csp.ts @@ -1,11 +1,11 @@ /* eslint-env node, mocha */ 'use strict' -const assert = require('assert') -const crypto = require('crypto') -const fs = require('fs') -const path = require('path') -const mock = require('mock-require') +import assert from 'assert' +import crypto from 'crypto' +import fs from 'fs' +import path from 'path' +import mock from 'mock-require' describe('Content security policies', function () { let defaultConfig, csp @@ -43,7 +43,7 @@ describe('Content security policies', function () { // beginnging Tests it('Disable CDN', function () { - let testconfig = defaultConfig + const testconfig = defaultConfig testconfig.useCDN = false mock('../lib/config', testconfig) csp = mock.reRequire('../lib/csp') @@ -57,7 +57,7 @@ describe('Content security policies', function () { }) it('Disable Google Analytics', function () { - let testconfig = defaultConfig + const testconfig = defaultConfig testconfig.csp.addGoogleAnalytics = false mock('../lib/config', testconfig) csp = mock.reRequire('../lib/csp') @@ -66,7 +66,7 @@ describe('Content security policies', function () { }) it('Disable Disqus', function () { - let testconfig = defaultConfig + const testconfig = defaultConfig testconfig.csp.addDisqus = false mock('../lib/config', testconfig) csp = mock.reRequire('../lib/csp') @@ -79,7 +79,7 @@ describe('Content security policies', function () { }) it('Set ReportURI', function () { - let testconfig = defaultConfig + const testconfig = defaultConfig testconfig.csp.reportURI = 'https://example.com/reportURI' mock('../lib/config', testconfig) csp = mock.reRequire('../lib/csp') @@ -88,7 +88,7 @@ describe('Content security policies', function () { }) it('Set own directives', function () { - let testconfig = defaultConfig + const testconfig = defaultConfig mock('../lib/config', defaultConfig) csp = mock.reRequire('../lib/csp') const unextendedCSP = csp.computeDirectives() diff --git a/src/test/letter-avatars.js b/src/test/letter-avatars.ts similarity index 100% rename from src/test/letter-avatars.js rename to src/test/letter-avatars.ts diff --git a/src/test/user.js b/src/test/user.ts similarity index 95% rename from src/test/user.js rename to src/test/user.ts index 38776a8f9..dd4f30378 100644 --- a/src/test/user.js +++ b/src/test/user.ts @@ -1,15 +1,11 @@ /* eslint-env node, mocha */ -'use strict' - -const assert = require('assert') - -const models = require('../lib/models') -const User = models.User +import { User, sequelize } from '../lib/models' +import assert = require('assert') describe('User Sequelize model', function () { beforeEach(() => { - return models.sequelize.sync({ force: true }) + return sequelize.sync({ force: true }) }) it('stores a password hash on creation and verifies that password', function () {