chore: vault tests refactors and lint (#2374)

This commit is contained in:
Karol Sójko
2023-08-02 00:23:56 +02:00
committed by GitHub
parent a0bc1d2488
commit 247daddf5a
96 changed files with 1463 additions and 751 deletions

View File

@@ -8,16 +8,21 @@ import {
import { PayloadManager } from './PayloadManager'
import { InternalEventBusInterface } from '@standardnotes/services'
import { ContentType } from '@standardnotes/domain-core'
import { LoggerInterface } from '@standardnotes/utils'
describe('payload manager', () => {
let payloadManager: PayloadManager
let internalEventBus: InternalEventBusInterface
let logger: LoggerInterface
beforeEach(() => {
internalEventBus = {} as jest.Mocked<InternalEventBusInterface>
internalEventBus.publish = jest.fn()
payloadManager = new PayloadManager(internalEventBus)
logger = {} as jest.Mocked<LoggerInterface>
logger.debug = jest.fn()
payloadManager = new PayloadManager(logger, internalEventBus)
})
it('emitting a payload should emit as-is and not merge on top of existing payload', async () => {

View File

@@ -1,6 +1,6 @@
import { ContentType } from '@standardnotes/domain-core'
import { PayloadsChangeObserver, QueueElement, PayloadsChangeObserverCallback, EmitQueue } from './Types'
import { removeFromArray, Uuids } from '@standardnotes/utils'
import { LoggerInterface, removeFromArray, Uuids } from '@standardnotes/utils'
import {
DeltaFileImport,
isDeletedPayload,
@@ -42,7 +42,10 @@ export class PayloadManager extends AbstractService implements PayloadManagerInt
public collection: PayloadCollection<FullyFormedPayloadInterface>
private emitQueue: EmitQueue<FullyFormedPayloadInterface> = []
constructor(protected override internalEventBus: InternalEventBusInterface) {
constructor(
private logger: LoggerInterface,
protected override internalEventBus: InternalEventBusInterface,
) {
super(internalEventBus)
this.collection = new PayloadCollection()
}
@@ -183,7 +186,7 @@ export class PayloadManager extends AbstractService implements PayloadManagerInt
continue
}
this.log(
this.logger.debug(
'applying payload',
apply.uuid,
'globalDirtyIndexAtLastSync',