import { DiscardItemsLocally } from './../UseCase/DiscardItemsLocally' import { InternalEventBusInterface } from './../Internal/InternalEventBusInterface' import { GetOwnedSharedVaults } from './UseCase/GetOwnedSharedVaults' import { DeleteSharedVault } from './UseCase/DeleteSharedVault' import { ConvertToSharedVault } from './UseCase/ConvertToSharedVault' import { ShareContactWithVault } from './UseCase/ShareContactWithVault' import { DeleteThirdPartyVault } from './UseCase/DeleteExternalSharedVault' import { FindContact } from './../Contacts/UseCase/FindContact' import { HandleKeyPairChange } from './../Contacts/UseCase/HandleKeyPairChange' import { CreateSharedVault } from './UseCase/CreateSharedVault' import { GetVault } from './../Vault/UseCase/GetVault' import { SharedVaultService } from './SharedVaultService' import { SyncServiceInterface } from '../Sync/SyncServiceInterface' import { ItemManagerInterface } from '../Item/ItemManagerInterface' import { SessionsClientInterface } from '../Session/SessionsClientInterface' import { ContactPublicKeySetInterface, TrustedContactInterface } from '@standardnotes/models' import { SyncLocalVaultsWithRemoteSharedVaults } from './UseCase/SyncLocalVaultsWithRemoteSharedVaults' describe('SharedVaultService', () => { let service: SharedVaultService let syncLocalVaultsWithRemoteSharedVaults: SyncLocalVaultsWithRemoteSharedVaults beforeEach(() => { const sync = {} as jest.Mocked sync.addEventObserver = jest.fn() const items = {} as jest.Mocked items.addObserver = jest.fn() const session = {} as jest.Mocked const getVault = {} as jest.Mocked const getOwnedVaults = {} as jest.Mocked const createSharedVaultUseCase = {} as jest.Mocked const handleKeyPairChange = {} as jest.Mocked const findContact = {} as jest.Mocked const deleteThirdPartyVault = {} as jest.Mocked const shareContactWithVault = {} as jest.Mocked const convertToSharedVault = {} as jest.Mocked const deleteSharedVaultUseCase = {} as jest.Mocked const discardItemsLocally = {} as jest.Mocked syncLocalVaultsWithRemoteSharedVaults = {} as jest.Mocked syncLocalVaultsWithRemoteSharedVaults.execute = jest.fn() const eventBus = {} as jest.Mocked eventBus.addEventHandler = jest.fn() service = new SharedVaultService( items, session, syncLocalVaultsWithRemoteSharedVaults, getVault, getOwnedVaults, createSharedVaultUseCase, handleKeyPairChange, findContact, deleteThirdPartyVault, shareContactWithVault, convertToSharedVault, deleteSharedVaultUseCase, discardItemsLocally, eventBus, ) }) describe('shareContactWithVaults', () => { it('should throw if attempting to share self contact', async () => { const contact = { name: 'Other', contactUuid: '456', publicKeySet: {} as ContactPublicKeySetInterface, isMe: true, } as jest.Mocked await expect(service.shareContactWithVaults(contact)).rejects.toThrow('Cannot share self contact') }) }) })