Migrate tests to TypeScript

Signed-off-by: David Mehren <dmehren1@gmail.com>
This commit is contained in:
David Mehren 2020-04-25 21:42:07 +02:00
parent 2121e271ac
commit 3b8c85cc9b
No known key found for this signature in database
GPG key ID: 6017AF117F9756CB
4 changed files with 15 additions and 18 deletions

View file

@ -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",

View file

@ -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()

View file

@ -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 () {