|
@@ -1,19 +1,14 @@
|
|
import { RevisionRepositoryInterface } from '../../Revision/RevisionRepositoryInterface'
|
|
import { RevisionRepositoryInterface } from '../../Revision/RevisionRepositoryInterface'
|
|
-import { RevisionRepositoryResolverInterface } from '../../Revision/RevisionRepositoryResolverInterface'
|
|
|
|
import { RemoveRevisionsFromSharedVault } from './RemoveRevisionsFromSharedVault'
|
|
import { RemoveRevisionsFromSharedVault } from './RemoveRevisionsFromSharedVault'
|
|
|
|
|
|
describe('RemoveRevisionsFromSharedVault', () => {
|
|
describe('RemoveRevisionsFromSharedVault', () => {
|
|
- let revisionRepositoryResolver: RevisionRepositoryResolverInterface
|
|
|
|
let revisionRepository: RevisionRepositoryInterface
|
|
let revisionRepository: RevisionRepositoryInterface
|
|
|
|
|
|
- const createUseCase = () => new RemoveRevisionsFromSharedVault(revisionRepositoryResolver)
|
|
|
|
|
|
+ const createUseCase = () => new RemoveRevisionsFromSharedVault(revisionRepository)
|
|
|
|
|
|
beforeEach(() => {
|
|
beforeEach(() => {
|
|
revisionRepository = {} as jest.Mocked<RevisionRepositoryInterface>
|
|
revisionRepository = {} as jest.Mocked<RevisionRepositoryInterface>
|
|
revisionRepository.clearSharedVaultAndKeySystemAssociations = jest.fn()
|
|
revisionRepository.clearSharedVaultAndKeySystemAssociations = jest.fn()
|
|
-
|
|
|
|
- revisionRepositoryResolver = {} as jest.Mocked<RevisionRepositoryResolverInterface>
|
|
|
|
- revisionRepositoryResolver.resolve = jest.fn().mockReturnValue(revisionRepository)
|
|
|
|
})
|
|
})
|
|
|
|
|
|
it('should clear shared vault and key system associations', async () => {
|
|
it('should clear shared vault and key system associations', async () => {
|
|
@@ -22,43 +17,38 @@ describe('RemoveRevisionsFromSharedVault', () => {
|
|
await useCase.execute({
|
|
await useCase.execute({
|
|
itemUuid: '00000000-0000-0000-0000-000000000000',
|
|
itemUuid: '00000000-0000-0000-0000-000000000000',
|
|
sharedVaultUuid: '00000000-0000-0000-0000-000000000001',
|
|
sharedVaultUuid: '00000000-0000-0000-0000-000000000001',
|
|
- roleNames: ['CORE_USER'],
|
|
|
|
})
|
|
})
|
|
|
|
|
|
expect(revisionRepository.clearSharedVaultAndKeySystemAssociations).toHaveBeenCalled()
|
|
expect(revisionRepository.clearSharedVaultAndKeySystemAssociations).toHaveBeenCalled()
|
|
})
|
|
})
|
|
|
|
|
|
- it('should return error when shared vault uuid is invalid', async () => {
|
|
|
|
|
|
+ it('should clear shared vault and key system associations for all items in a vault when item uuid is not provided', async () => {
|
|
const useCase = createUseCase()
|
|
const useCase = createUseCase()
|
|
|
|
|
|
- const result = await useCase.execute({
|
|
|
|
- itemUuid: '00000000-0000-0000-0000-000000000000',
|
|
|
|
- sharedVaultUuid: 'invalid',
|
|
|
|
- roleNames: ['CORE_USER'],
|
|
|
|
|
|
+ await useCase.execute({
|
|
|
|
+ sharedVaultUuid: '00000000-0000-0000-0000-000000000001',
|
|
})
|
|
})
|
|
|
|
|
|
- expect(result.isFailed()).toBe(true)
|
|
|
|
|
|
+ expect(revisionRepository.clearSharedVaultAndKeySystemAssociations).toHaveBeenCalled()
|
|
})
|
|
})
|
|
|
|
|
|
- it('should return error when item uuid is invalid', async () => {
|
|
|
|
|
|
+ it('should return error when shared vault uuid is invalid', async () => {
|
|
const useCase = createUseCase()
|
|
const useCase = createUseCase()
|
|
|
|
|
|
const result = await useCase.execute({
|
|
const result = await useCase.execute({
|
|
- itemUuid: 'invalid',
|
|
|
|
- sharedVaultUuid: '00000000-0000-0000-0000-000000000001',
|
|
|
|
- roleNames: ['CORE_USER'],
|
|
|
|
|
|
+ itemUuid: '00000000-0000-0000-0000-000000000000',
|
|
|
|
+ sharedVaultUuid: 'invalid',
|
|
})
|
|
})
|
|
|
|
|
|
expect(result.isFailed()).toBe(true)
|
|
expect(result.isFailed()).toBe(true)
|
|
})
|
|
})
|
|
|
|
|
|
- it('should return error when role names are invalid', async () => {
|
|
|
|
|
|
+ it('should return error when item uuid is invalid', async () => {
|
|
const useCase = createUseCase()
|
|
const useCase = createUseCase()
|
|
|
|
|
|
const result = await useCase.execute({
|
|
const result = await useCase.execute({
|
|
- itemUuid: '00000000-0000-0000-0000-000000000000',
|
|
|
|
|
|
+ itemUuid: 'invalid',
|
|
sharedVaultUuid: '00000000-0000-0000-0000-000000000001',
|
|
sharedVaultUuid: '00000000-0000-0000-0000-000000000001',
|
|
- roleNames: ['invalid'],
|
|
|
|
})
|
|
})
|
|
|
|
|
|
expect(result.isFailed()).toBe(true)
|
|
expect(result.isFailed()).toBe(true)
|