mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2025-05-18 17:25:16 -04:00
ESLint fixes for tests 🚨
Signed-off-by: David Mehren <dmehren1@gmail.com>
This commit is contained in:
parent
ac030760ba
commit
7359b468e4
2 changed files with 14 additions and 14 deletions
|
@ -5,8 +5,8 @@ import assert from 'assert'
|
||||||
import crypto from 'crypto'
|
import crypto from 'crypto'
|
||||||
import fs from 'fs'
|
import fs from 'fs'
|
||||||
import path from 'path'
|
import path from 'path'
|
||||||
import * as configModule from '../lib/config';
|
import * as configModule from '../lib/config'
|
||||||
import { ImportMock } from 'ts-mock-imports';
|
import { ImportMock } from 'ts-mock-imports'
|
||||||
|
|
||||||
describe('Content security policies', function () {
|
describe('Content security policies', function () {
|
||||||
let defaultConfig, csp
|
let defaultConfig, csp
|
||||||
|
@ -36,7 +36,7 @@ describe('Content security policies', function () {
|
||||||
it('Disable CDN', function () {
|
it('Disable CDN', function () {
|
||||||
const testconfig = defaultConfig
|
const testconfig = defaultConfig
|
||||||
testconfig.useCDN = false
|
testconfig.useCDN = false
|
||||||
ImportMock.mockOther(configModule, 'config', testconfig);
|
ImportMock.mockOther(configModule, 'config', testconfig)
|
||||||
|
|
||||||
assert(!csp.computeDirectives().scriptSrc.includes('https://cdnjs.cloudflare.com'))
|
assert(!csp.computeDirectives().scriptSrc.includes('https://cdnjs.cloudflare.com'))
|
||||||
assert(!csp.computeDirectives().scriptSrc.includes('https://cdn.mathjax.org'))
|
assert(!csp.computeDirectives().scriptSrc.includes('https://cdn.mathjax.org'))
|
||||||
|
@ -49,7 +49,7 @@ describe('Content security policies', function () {
|
||||||
it('Disable Google Analytics', function () {
|
it('Disable Google Analytics', function () {
|
||||||
const testconfig = defaultConfig
|
const testconfig = defaultConfig
|
||||||
testconfig.csp.addGoogleAnalytics = false
|
testconfig.csp.addGoogleAnalytics = false
|
||||||
ImportMock.mockOther(configModule, 'config', testconfig);
|
ImportMock.mockOther(configModule, 'config', testconfig)
|
||||||
|
|
||||||
assert(!csp.computeDirectives().scriptSrc.includes('https://www.google-analytics.com'))
|
assert(!csp.computeDirectives().scriptSrc.includes('https://www.google-analytics.com'))
|
||||||
})
|
})
|
||||||
|
@ -57,7 +57,7 @@ describe('Content security policies', function () {
|
||||||
it('Disable Disqus', function () {
|
it('Disable Disqus', function () {
|
||||||
const testconfig = defaultConfig
|
const testconfig = defaultConfig
|
||||||
testconfig.csp.addDisqus = false
|
testconfig.csp.addDisqus = false
|
||||||
ImportMock.mockOther(configModule, 'config', testconfig);
|
ImportMock.mockOther(configModule, 'config', testconfig)
|
||||||
|
|
||||||
assert(!csp.computeDirectives().scriptSrc.includes('https://disqus.com'))
|
assert(!csp.computeDirectives().scriptSrc.includes('https://disqus.com'))
|
||||||
assert(!csp.computeDirectives().scriptSrc.includes('https://*.disqus.com'))
|
assert(!csp.computeDirectives().scriptSrc.includes('https://*.disqus.com'))
|
||||||
|
@ -69,14 +69,14 @@ describe('Content security policies', function () {
|
||||||
it('Set ReportURI', function () {
|
it('Set ReportURI', function () {
|
||||||
const testconfig = defaultConfig
|
const testconfig = defaultConfig
|
||||||
testconfig.csp.reportURI = 'https://example.com/reportURI'
|
testconfig.csp.reportURI = 'https://example.com/reportURI'
|
||||||
ImportMock.mockOther(configModule, 'config', testconfig);
|
ImportMock.mockOther(configModule, 'config', testconfig)
|
||||||
|
|
||||||
assert.strictEqual(csp.computeDirectives().reportUri, 'https://example.com/reportURI')
|
assert.strictEqual(csp.computeDirectives().reportUri, 'https://example.com/reportURI')
|
||||||
})
|
})
|
||||||
|
|
||||||
it('Set own directives', function () {
|
it('Set own directives', function () {
|
||||||
const testconfig = defaultConfig
|
const testconfig = defaultConfig
|
||||||
ImportMock.mockOther(configModule, 'config', testconfig);
|
ImportMock.mockOther(configModule, 'config', testconfig)
|
||||||
const unextendedCSP = csp.computeDirectives()
|
const unextendedCSP = csp.computeDirectives()
|
||||||
testconfig.csp.directives = {
|
testconfig.csp.directives = {
|
||||||
defaultSrc: ['https://default.example.com'],
|
defaultSrc: ['https://default.example.com'],
|
||||||
|
@ -89,7 +89,7 @@ describe('Content security policies', function () {
|
||||||
childSrc: ['https://child.example.com'],
|
childSrc: ['https://child.example.com'],
|
||||||
connectSrc: ['https://connect.example.com']
|
connectSrc: ['https://connect.example.com']
|
||||||
}
|
}
|
||||||
ImportMock.mockOther(configModule, 'config', testconfig);
|
ImportMock.mockOther(configModule, 'config', testconfig)
|
||||||
|
|
||||||
const variations = ['default', 'script', 'img', 'style', 'font', 'object', 'media', 'child', 'connect']
|
const variations = ['default', 'script', 'img', 'style', 'font', 'object', 'media', 'child', 'connect']
|
||||||
|
|
||||||
|
|
|
@ -5,18 +5,18 @@
|
||||||
import { ImportMock } from 'ts-mock-imports'
|
import { ImportMock } from 'ts-mock-imports'
|
||||||
import * as configModule from '../lib/config'
|
import * as configModule from '../lib/config'
|
||||||
|
|
||||||
const assert = require('assert')
|
import assert from 'assert'
|
||||||
const avatars = require('../lib/letter-avatars')
|
import * as avatars from '../lib/letter-avatars'
|
||||||
|
|
||||||
describe('generateAvatarURL() gravatar enabled', function () {
|
describe('generateAvatarURL() gravatar enabled', function () {
|
||||||
beforeEach(function () {
|
beforeEach(function () {
|
||||||
// Reset config to make sure we don't influence other tests
|
// Reset config to make sure we don't influence other tests
|
||||||
let testconfig = {
|
const testconfig = {
|
||||||
allowGravatar: true,
|
allowGravatar: true,
|
||||||
serverURL: 'http://localhost:3000',
|
serverURL: 'http://localhost:3000',
|
||||||
port: 3000
|
port: 3000
|
||||||
}
|
}
|
||||||
ImportMock.mockOther(configModule, 'config', testconfig);
|
ImportMock.mockOther(configModule, 'config', testconfig)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should return correct urls', function () {
|
it('should return correct urls', function () {
|
||||||
|
@ -32,12 +32,12 @@ describe('generateAvatarURL() gravatar enabled', function () {
|
||||||
describe('generateAvatarURL() gravatar disabled', function () {
|
describe('generateAvatarURL() gravatar disabled', function () {
|
||||||
beforeEach(function () {
|
beforeEach(function () {
|
||||||
// Reset config to make sure we don't influence other tests
|
// Reset config to make sure we don't influence other tests
|
||||||
let testconfig = {
|
const testconfig = {
|
||||||
allowGravatar: false,
|
allowGravatar: false,
|
||||||
serverURL: 'http://localhost:3000',
|
serverURL: 'http://localhost:3000',
|
||||||
port: 3000
|
port: 3000
|
||||||
}
|
}
|
||||||
ImportMock.mockOther(configModule, 'config', testconfig);
|
ImportMock.mockOther(configModule, 'config', testconfig)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should return correct urls', function () {
|
it('should return correct urls', function () {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue