mirror of
https://github.com/Cameri/nostream.git
synced 2025-03-30 12:35:50 +02:00
43 lines
1.1 KiB
TypeScript
43 lines
1.1 KiB
TypeScript
import { expect } from 'chai'
|
|
import Sinon from 'sinon'
|
|
|
|
import * as databaseClientModule from '../../../src/database/client'
|
|
|
|
import { AppWorker } from '../../../src/app/worker'
|
|
import { SettingsStatic } from '../../../src/utils/settings'
|
|
import { workerFactory } from '../../../src/factories/worker-factory'
|
|
|
|
|
|
describe('workerFactory', () => {
|
|
let createSettingsStub: Sinon.SinonStub
|
|
let getMasterDbClientStub: Sinon.SinonStub
|
|
let getReadReplicaDbClientStub: Sinon.SinonStub
|
|
|
|
beforeEach(() => {
|
|
createSettingsStub = Sinon.stub(SettingsStatic, 'createSettings')
|
|
getMasterDbClientStub = Sinon.stub(databaseClientModule, 'getMasterDbClient')
|
|
getReadReplicaDbClientStub = Sinon.stub(databaseClientModule, 'getReadReplicaDbClient')
|
|
})
|
|
|
|
afterEach(() => {
|
|
getReadReplicaDbClientStub.restore()
|
|
getMasterDbClientStub.restore()
|
|
createSettingsStub.restore()
|
|
})
|
|
|
|
it('returns an AppWorker', () => {
|
|
createSettingsStub.returns({
|
|
info: {
|
|
relay_url: 'url',
|
|
},
|
|
network: {
|
|
|
|
},
|
|
})
|
|
|
|
const worker = workerFactory()
|
|
expect(worker).to.be.an.instanceOf(AppWorker)
|
|
worker.close()
|
|
})
|
|
})
|