ESLint fixes for tests 🚨

Signed-off-by: David Mehren <dmehren1@gmail.com>
This commit is contained in:
David Mehren 2020-05-09 14:05:27 +02:00
parent ac030760ba
commit 7359b468e4
No known key found for this signature in database
GPG key ID: 6017AF117F9756CB
2 changed files with 14 additions and 14 deletions

View file

@ -5,8 +5,8 @@ import assert from 'assert'
import crypto from 'crypto'
import fs from 'fs'
import path from 'path'
import * as configModule from '../lib/config';
import { ImportMock } from 'ts-mock-imports';
import * as configModule from '../lib/config'
import { ImportMock } from 'ts-mock-imports'
describe('Content security policies', function () {
let defaultConfig, csp
@ -36,7 +36,7 @@ describe('Content security policies', function () {
it('Disable CDN', function () {
const testconfig = defaultConfig
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://cdn.mathjax.org'))
@ -49,7 +49,7 @@ describe('Content security policies', function () {
it('Disable Google Analytics', function () {
const testconfig = defaultConfig
testconfig.csp.addGoogleAnalytics = false
ImportMock.mockOther(configModule, 'config', testconfig);
ImportMock.mockOther(configModule, 'config', testconfig)
assert(!csp.computeDirectives().scriptSrc.includes('https://www.google-analytics.com'))
})
@ -57,7 +57,7 @@ describe('Content security policies', function () {
it('Disable Disqus', function () {
const testconfig = defaultConfig
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'))
@ -69,14 +69,14 @@ describe('Content security policies', function () {
it('Set ReportURI', function () {
const testconfig = defaultConfig
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')
})
it('Set own directives', function () {
const testconfig = defaultConfig
ImportMock.mockOther(configModule, 'config', testconfig);
ImportMock.mockOther(configModule, 'config', testconfig)
const unextendedCSP = csp.computeDirectives()
testconfig.csp.directives = {
defaultSrc: ['https://default.example.com'],
@ -89,7 +89,7 @@ describe('Content security policies', function () {
childSrc: ['https://child.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']

View file

@ -5,18 +5,18 @@
import { ImportMock } from 'ts-mock-imports'
import * as configModule from '../lib/config'
const assert = require('assert')
const avatars = require('../lib/letter-avatars')
import assert from 'assert'
import * as avatars from '../lib/letter-avatars'
describe('generateAvatarURL() gravatar enabled', function () {
beforeEach(function () {
// Reset config to make sure we don't influence other tests
let testconfig = {
const testconfig = {
allowGravatar: true,
serverURL: 'http://localhost:3000',
port: 3000
}
ImportMock.mockOther(configModule, 'config', testconfig);
ImportMock.mockOther(configModule, 'config', testconfig)
})
it('should return correct urls', function () {
@ -32,12 +32,12 @@ describe('generateAvatarURL() gravatar enabled', function () {
describe('generateAvatarURL() gravatar disabled', function () {
beforeEach(function () {
// Reset config to make sure we don't influence other tests
let testconfig = {
const testconfig = {
allowGravatar: false,
serverURL: 'http://localhost:3000',
port: 3000
}
ImportMock.mockOther(configModule, 'config', testconfig);
ImportMock.mockOther(configModule, 'config', testconfig)
})
it('should return correct urls', function () {