Skip to content

Commit

Permalink
fix: third-party-providers-storage tests
Browse files Browse the repository at this point in the history
  • Loading branch information
aleortega committed Jan 28, 2025
1 parent 12ab4e3 commit f71d994
Showing 1 changed file with 6 additions and 27 deletions.
33 changes: 6 additions & 27 deletions test/unit/logic/third-party-providers-storage.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,10 @@ describe('third-party-providers-storage', () => {
const thirdPartyProvidersGraphFetcherMock = {
get: () => Promise.reject(new Error())
}
const thirdPartyProvidersServiceFetcherMock = {
get: () => Promise.reject(new Error())
}

const sut = await createThirdPartyProvidersStorage({
logs,
thirdPartyProvidersGraphFetcher: thirdPartyProvidersGraphFetcherMock,
thirdPartyProvidersServiceFetcher: thirdPartyProvidersServiceFetcherMock
thirdPartyProvidersGraphFetcher: thirdPartyProvidersGraphFetcherMock
})

// Act & Assert
Expand All @@ -45,16 +41,12 @@ describe('third-party-providers-storage', () => {
// Arrange
const logs = await createLogComponent({})
const thirdPartyProvidersGraphFetcherMock = {
get: jest.fn().mockRejectedValue(new Error())
}
const thirdPartyProvidersServiceFetcherMock = {
get: jest.fn().mockResolvedValue(thirdPartyProviders)
}

const sut = await createThirdPartyProvidersStorage({
logs,
thirdPartyProvidersGraphFetcher: thirdPartyProvidersGraphFetcherMock,
thirdPartyProvidersServiceFetcher: thirdPartyProvidersServiceFetcherMock
thirdPartyProvidersGraphFetcher: thirdPartyProvidersGraphFetcherMock
})

// Act
Expand All @@ -63,7 +55,7 @@ describe('third-party-providers-storage', () => {

// Assert
expect(response).toEqual(thirdPartyProviders)
expect(thirdPartyProvidersGraphFetcherMock.get).not.toHaveBeenCalled()
expect(thirdPartyProvidersGraphFetcherMock.get).toHaveBeenCalled()
})

it('should start if providers could be fetched from graph', async () => {
Expand All @@ -72,14 +64,10 @@ describe('third-party-providers-storage', () => {
const thirdPartyProvidersGraphFetcherMock = {
get: jest.fn().mockResolvedValue(thirdPartyProviders)
}
const thirdPartyProvidersServiceFetcherMock = {
get: jest.fn().mockRejectedValue(new Error())
}

const sut = await createThirdPartyProvidersStorage({
logs,
thirdPartyProvidersGraphFetcher: thirdPartyProvidersGraphFetcherMock,
thirdPartyProvidersServiceFetcher: thirdPartyProvidersServiceFetcherMock
thirdPartyProvidersGraphFetcher: thirdPartyProvidersGraphFetcherMock
})

// Act
Expand All @@ -88,24 +76,19 @@ describe('third-party-providers-storage', () => {

// Assert
expect(response).toEqual(thirdPartyProviders)
expect(thirdPartyProvidersServiceFetcherMock.get).toHaveBeenCalled()
expect(thirdPartyProvidersGraphFetcherMock.get).toHaveBeenCalled()
})

it('should return undefined if the Third Party Provider requested does not exists', async () => {
// Arrange
const logs = await createLogComponent({})
const thirdPartyProvidersGraphFetcherMock = {
get: jest.fn().mockRejectedValue(new Error())
}
const thirdPartyProvidersServiceFetcherMock = {
get: jest.fn().mockResolvedValue(thirdPartyProviders)
}

const sut = await createThirdPartyProvidersStorage({
logs,
thirdPartyProvidersGraphFetcher: thirdPartyProvidersGraphFetcherMock,
thirdPartyProvidersServiceFetcher: thirdPartyProvidersServiceFetcherMock
thirdPartyProvidersGraphFetcher: thirdPartyProvidersGraphFetcherMock
})
const nonExistentThirdPartyNameUrn = await parseUrn('urn:decentraland:matic:collections-thirdparty:non-existent')

Expand All @@ -122,16 +105,12 @@ describe('third-party-providers-storage', () => {
// Arrange
const logs = await createLogComponent({})
const thirdPartyProvidersGraphFetcherMock = {
get: jest.fn().mockRejectedValue(new Error())
}
const thirdPartyProvidersServiceFetcherMock = {
get: jest.fn().mockResolvedValue(thirdPartyProviders)
}

const sut = await createThirdPartyProvidersStorage({
logs,
thirdPartyProvidersGraphFetcher: thirdPartyProvidersGraphFetcherMock,
thirdPartyProvidersServiceFetcher: thirdPartyProvidersServiceFetcherMock
thirdPartyProvidersGraphFetcher: thirdPartyProvidersGraphFetcherMock
})
const thirdPartyNameUrn = await parseUrn('urn:decentraland:matic:collections-thirdparty:cryptoavatars')

Expand Down

0 comments on commit f71d994

Please sign in to comment.