mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2025-05-19 09:45:37 -04:00
Migrate tests to TypeScript
Signed-off-by: David Mehren <dmehren1@gmail.com>
This commit is contained in:
parent
2121e271ac
commit
3b8c85cc9b
4 changed files with 15 additions and 18 deletions
|
@ -8,7 +8,7 @@
|
||||||
"test": "npm run-script eslint && npm run-script jsonlint && npm run-script mocha-suite",
|
"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",
|
"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",
|
"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",
|
"standard": "echo 'standard is no longer being used, use `npm run eslint` instead!' && exit 1",
|
||||||
"dev": "webpack --config webpack.dev.js --progress --colors --watch",
|
"dev": "webpack --config webpack.dev.js --progress --colors --watch",
|
||||||
"heroku-prebuild": "bin/heroku",
|
"heroku-prebuild": "bin/heroku",
|
||||||
|
@ -175,6 +175,7 @@
|
||||||
"@types/helmet": "^0.0.45",
|
"@types/helmet": "^0.0.45",
|
||||||
"@types/lodash": "^4.14.149",
|
"@types/lodash": "^4.14.149",
|
||||||
"@types/minio": "^7.0.5",
|
"@types/minio": "^7.0.5",
|
||||||
|
"@types/mocha": "^7.0.2",
|
||||||
"@types/node": "^13.11.1",
|
"@types/node": "^13.11.1",
|
||||||
"@types/passport": "^1.0.3",
|
"@types/passport": "^1.0.3",
|
||||||
"@types/passport-facebook": "^2.1.9",
|
"@types/passport-facebook": "^2.1.9",
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
/* eslint-env node, mocha */
|
/* eslint-env node, mocha */
|
||||||
'use strict'
|
'use strict'
|
||||||
|
|
||||||
const assert = require('assert')
|
import assert from 'assert'
|
||||||
const crypto = require('crypto')
|
import crypto from 'crypto'
|
||||||
const fs = require('fs')
|
import fs from 'fs'
|
||||||
const path = require('path')
|
import path from 'path'
|
||||||
const mock = require('mock-require')
|
import mock from 'mock-require'
|
||||||
|
|
||||||
describe('Content security policies', function () {
|
describe('Content security policies', function () {
|
||||||
let defaultConfig, csp
|
let defaultConfig, csp
|
||||||
|
@ -43,7 +43,7 @@ describe('Content security policies', function () {
|
||||||
|
|
||||||
// beginnging Tests
|
// beginnging Tests
|
||||||
it('Disable CDN', function () {
|
it('Disable CDN', function () {
|
||||||
let testconfig = defaultConfig
|
const testconfig = defaultConfig
|
||||||
testconfig.useCDN = false
|
testconfig.useCDN = false
|
||||||
mock('../lib/config', testconfig)
|
mock('../lib/config', testconfig)
|
||||||
csp = mock.reRequire('../lib/csp')
|
csp = mock.reRequire('../lib/csp')
|
||||||
|
@ -57,7 +57,7 @@ describe('Content security policies', function () {
|
||||||
})
|
})
|
||||||
|
|
||||||
it('Disable Google Analytics', function () {
|
it('Disable Google Analytics', function () {
|
||||||
let testconfig = defaultConfig
|
const testconfig = defaultConfig
|
||||||
testconfig.csp.addGoogleAnalytics = false
|
testconfig.csp.addGoogleAnalytics = false
|
||||||
mock('../lib/config', testconfig)
|
mock('../lib/config', testconfig)
|
||||||
csp = mock.reRequire('../lib/csp')
|
csp = mock.reRequire('../lib/csp')
|
||||||
|
@ -66,7 +66,7 @@ describe('Content security policies', function () {
|
||||||
})
|
})
|
||||||
|
|
||||||
it('Disable Disqus', function () {
|
it('Disable Disqus', function () {
|
||||||
let testconfig = defaultConfig
|
const testconfig = defaultConfig
|
||||||
testconfig.csp.addDisqus = false
|
testconfig.csp.addDisqus = false
|
||||||
mock('../lib/config', testconfig)
|
mock('../lib/config', testconfig)
|
||||||
csp = mock.reRequire('../lib/csp')
|
csp = mock.reRequire('../lib/csp')
|
||||||
|
@ -79,7 +79,7 @@ describe('Content security policies', function () {
|
||||||
})
|
})
|
||||||
|
|
||||||
it('Set ReportURI', function () {
|
it('Set ReportURI', function () {
|
||||||
let testconfig = defaultConfig
|
const testconfig = defaultConfig
|
||||||
testconfig.csp.reportURI = 'https://example.com/reportURI'
|
testconfig.csp.reportURI = 'https://example.com/reportURI'
|
||||||
mock('../lib/config', testconfig)
|
mock('../lib/config', testconfig)
|
||||||
csp = mock.reRequire('../lib/csp')
|
csp = mock.reRequire('../lib/csp')
|
||||||
|
@ -88,7 +88,7 @@ describe('Content security policies', function () {
|
||||||
})
|
})
|
||||||
|
|
||||||
it('Set own directives', function () {
|
it('Set own directives', function () {
|
||||||
let testconfig = defaultConfig
|
const testconfig = defaultConfig
|
||||||
mock('../lib/config', defaultConfig)
|
mock('../lib/config', defaultConfig)
|
||||||
csp = mock.reRequire('../lib/csp')
|
csp = mock.reRequire('../lib/csp')
|
||||||
const unextendedCSP = csp.computeDirectives()
|
const unextendedCSP = csp.computeDirectives()
|
|
@ -1,15 +1,11 @@
|
||||||
/* eslint-env node, mocha */
|
/* eslint-env node, mocha */
|
||||||
|
|
||||||
'use strict'
|
import { User, sequelize } from '../lib/models'
|
||||||
|
import assert = require('assert')
|
||||||
const assert = require('assert')
|
|
||||||
|
|
||||||
const models = require('../lib/models')
|
|
||||||
const User = models.User
|
|
||||||
|
|
||||||
describe('User Sequelize model', function () {
|
describe('User Sequelize model', function () {
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
return models.sequelize.sync({ force: true })
|
return sequelize.sync({ force: true })
|
||||||
})
|
})
|
||||||
|
|
||||||
it('stores a password hash on creation and verifies that password', function () {
|
it('stores a password hash on creation and verifies that password', function () {
|
Loading…
Add table
Add a link
Reference in a new issue