fix tests

This commit is contained in:
Hongbo Wu 2024-02-22 12:03:58 +08:00
parent 34db7bb2d8
commit 8b848912c9
10 changed files with 20 additions and 24 deletions

View file

@ -15,7 +15,7 @@ export const mochaGlobalTeardown = async () => {
console.log('redis connection closed')
if (redisDataSource.workerRedisClient) {
stopWorker()
await stopWorker()
console.log('worker closed')
}
}

View file

@ -26,7 +26,7 @@ describe('Sanitize Directive', () => {
})
describe('Update user with a bio that is too long', () => {
let bio = ''.padStart(500, '*')
const bio = ''.padStart(500, '*')
let query: string
beforeEach(() => {

View file

@ -30,7 +30,7 @@ describe('Emails Router', () => {
user = await createTestUser('fakeUser')
newsletterEmail = await createNewsletterEmail(user.id)
token = process.env.PUBSUB_VERIFICATION_TOKEN!
token = process.env.PUBSUB_VERIFICATION_TOKEN || ''
receivedEmail = await saveReceivedEmail(
from,
newsletterEmail.address,
@ -52,7 +52,7 @@ describe('Emails Router', () => {
describe('forward', () => {
const html = '<html>test html</html>'
beforeEach(async () => {
beforeEach(() => {
sinon.replace(
sendNotification,
'sendMulticastPushNotifications',

View file

@ -1,5 +1,5 @@
import { request } from '../util'
import 'mocha'
import { request } from '../util'
describe('Upload Router', () => {
const token = process.env.PUBSUB_VERIFICATION_TOKEN || ''

View file

@ -1,5 +1,5 @@
import 'mocha'
import { expect } from 'chai'
import 'mocha'
import { validateUrl } from '../../src/services/create_page_save_request'
describe('validateUrl', () => {

View file

@ -1,12 +1,12 @@
import 'mocha'
import { expect } from 'chai'
import 'mocha'
import { getHighlightLocation } from '../../src/services/highlights'
describe('getHighlightLocation', () => {
let patch: string
let location: number
before(async () => {
before(() => {
location = 109
patch = `@@ -${location + 1},16 +${location + 1},36 @@
. We're
@ -18,7 +18,7 @@ describe('getHighlightLocation', () => {
coming`
})
it('returns highlight location from patch', async () => {
it('returns highlight location from patch', () => {
const result = getHighlightLocation(patch)
expect(result).to.eql(location)
})

View file

@ -20,7 +20,7 @@ export const stopApolloServer = async () => {
await apollo.stop()
}
export const startWorker = async (connection: ConnectionOptions) => {
export const startWorker = (connection: ConnectionOptions) => {
worker = createWorker(connection)
queueEvents = new QueueEvents(QUEUE_NAME, {
connection,
@ -28,8 +28,8 @@ export const startWorker = async (connection: ConnectionOptions) => {
}
export const stopWorker = async () => {
queueEvents.close()
worker.close()
await queueEvents.close()
await worker.close()
}
export const waitUntilJobsDone = async (jobs: Job[]) => {

View file

@ -1,5 +1,5 @@
import 'mocha'
import { expect } from 'chai'
import 'mocha'
import { validatedDate } from '../../src/utils/helpers'
describe('validatedDate', () => {

View file

@ -1,7 +1,11 @@
import 'mocha'
import * as chai from 'chai'
import { expect } from 'chai'
import chaiAsPromised from 'chai-as-promised'
import fs from 'fs'
import 'mocha'
import nock from 'nock'
import { User } from '../../src/entity/user'
import { deleteUser } from '../../src/services/user'
import {
getTitleFromEmailSubject,
isProbablyArticle,
@ -9,11 +13,7 @@ import {
parsePageMetadata,
parsePreparedContent,
} from '../../src/utils/parser'
import nock from 'nock'
import chaiAsPromised from 'chai-as-promised'
import { User } from '../../src/entity/user'
import { createTestUser } from '../db'
import { deleteUser } from '../../src/services/user'
chai.use(chaiAsPromised)

View file

@ -6,10 +6,6 @@
"compilerOptions": {
"outDir": "dist"
},
"include": [
"src",
"test",
"../integration-handler/test/integrations.test.ts"
],
"exclude": ["./src/generated", "./test"]
"include": ["src", "test"],
"exclude": ["./src/generated"]
}