Skip to content

Commit

Permalink
chore: beforeEachs
Browse files Browse the repository at this point in the history
  • Loading branch information
nicosantangelo committed Jan 4, 2022
1 parent 3bb84fc commit e71c91e
Showing 1 changed file with 27 additions and 9 deletions.
36 changes: 27 additions & 9 deletions src/Curation/Curation.service.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,35 +40,44 @@ describe('when getting the access to an element', () => {
})

describe('when the address belongs to the committe', () => {
it('should resolve to true', () => {
beforeEach(() => {
mockIsCommitteeMember.mockResolvedValueOnce(true)
mockGetMergedCollection.mockResolvedValueOnce(collection)
})

it('should resolve to true', () => {
return testHasAccessToCollectionToBe(true)
})
})

describe('when the collection belongs to the address', () => {
it('should resolve to true', () => {
beforeEach(() => {
mockGetMergedCollection.mockResolvedValueOnce(collection)
isOwnedBySpy.mockResolvedValueOnce(true)
})

it('should resolve to true', () => {
return testHasAccessToCollectionToBe(true)
})
})

describe('when the address is a manager of the collection', () => {
it('should resolve to true', () => {
beforeEach(() => {
mockGetMergedCollection.mockResolvedValueOnce(collection)
})

it('should resolve to true', () => {
return testHasAccessToCollectionToBe(true)
})
})

describe('when the none of the managers of a collection match with the provided address', () => {
beforeEach(() => {
collection = { ...collection, managers: ['another address'] }
mockGetMergedCollection.mockResolvedValueOnce(collection)
})

it('should resolve to false', () => {
mockGetMergedCollection.mockResolvedValueOnce(collection)
return testHasAccessToCollectionToBe(false)
})
})
Expand Down Expand Up @@ -99,37 +108,46 @@ describe('when getting the access to an element', () => {
})

describe('when the address belongs to the committe', () => {
it('should resolve to true', () => {
beforeEach(() => {
mockIsCommitteeMember.mockResolvedValueOnce(true)
mockGetMergedItem.mockResolvedValueOnce(item)
})

it('should resolve to true', () => {
return testHasAccessToItemToBe(true)
})
})

describe('when the item belongs to the address', () => {
it('should resolve to true', () => {
beforeEach(() => {
mockGetMergedItem.mockResolvedValueOnce(collection)
isOwnedBySpy.mockResolvedValueOnce(true)
})

it('should resolve to true', () => {
return testHasAccessToItemToBe(true)
})
})

describe('when the address is a manager of the collection', () => {
it('should resolve to true', () => {
beforeEach(() => {
mockGetMergedItem.mockResolvedValueOnce(item)
mockGetMergedCollection.mockResolvedValueOnce(collection)
})

it('should resolve to true', () => {
return testHasAccessToItemToBe(true)
})
})

describe('when the none of the managers of a collection match with the provided address', () => {
beforeEach(() => {
collection = { ...collection, managers: ['another address'] }
mockGetMergedItem.mockResolvedValueOnce(item)
mockGetMergedCollection.mockResolvedValueOnce(collection)
})

it('should resolve to false', () => {
mockGetMergedItem.mockResolvedValueOnce(item)
mockGetMergedCollection.mockResolvedValueOnce(collection)
return testHasAccessToItemToBe(false)
})
})
Expand Down

0 comments on commit e71c91e

Please sign in to comment.