-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #112 from poap-xyz/fix/filter-poaps-with-collector…
…-and-not-null-filter Fix fetch POAPs with collector and without null address filter
- Loading branch information
Showing
13 changed files
with
221 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -29,7 +29,7 @@ jobs: | |
git config user.email "[email protected]" | ||
- name: Install dependencies | ||
run: yarn install --frozen-lockfile | ||
run: yarn install --immutable | ||
|
||
- name: Check package versions and publish | ||
run: yarn publish-beta $GITHUB_REF_NAME | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,188 @@ | ||
import { MockProxy, anyString, mock } from 'jest-mock-extended'; | ||
import { CompassProvider, TokensApiProvider } from '@poap-xyz/providers'; | ||
import { PoapsClient } from '../src/PoapsClient'; | ||
|
||
describe('PoapsClient', () => { | ||
let compassProviderMock: MockProxy<CompassProvider>; | ||
let tokensApiProviderMock: MockProxy<TokensApiProvider>; | ||
|
||
let poapsClient: PoapsClient; | ||
|
||
beforeEach(() => { | ||
compassProviderMock = mock<CompassProvider>(); | ||
tokensApiProviderMock = mock<TokensApiProvider>(); | ||
|
||
poapsClient = new PoapsClient(compassProviderMock, tokensApiProviderMock); | ||
}); | ||
|
||
describe('fetch', () => { | ||
it('request all tokens except zero address and dead address when no filter is given', async () => { | ||
// Given | ||
compassProviderMock.request.mockResolvedValue({ | ||
data: { | ||
poaps: [], | ||
}, | ||
}); | ||
|
||
// When | ||
await poapsClient.fetch({ | ||
limit: 1, | ||
offset: 0, | ||
}); | ||
|
||
// Then | ||
expect(compassProviderMock.request).toHaveBeenCalledWith(anyString(), { | ||
limit: 1, | ||
offset: 0, | ||
orderBy: {}, | ||
where: { | ||
collector_address: { | ||
_nin: [ | ||
'0x0000000000000000000000000000000000000000', | ||
'0x000000000000000000000000000000000000dead', | ||
], | ||
}, | ||
}, | ||
}); | ||
}); | ||
|
||
it('request all tokens including zero address and dead address when those filters are given on false', async () => { | ||
// Given | ||
compassProviderMock.request.mockResolvedValue({ | ||
data: { | ||
poaps: [], | ||
}, | ||
}); | ||
|
||
// When | ||
await poapsClient.fetch({ | ||
limit: 1, | ||
offset: 0, | ||
filterZeroAddress: false, | ||
filterDeadAddress: false, | ||
}); | ||
|
||
// Then | ||
expect(compassProviderMock.request).toHaveBeenCalledWith(anyString(), { | ||
limit: 1, | ||
offset: 0, | ||
orderBy: {}, | ||
where: {}, | ||
}); | ||
}); | ||
|
||
it('request all tokens except dead address but include zero address when filter is given on false', async () => { | ||
// Given | ||
compassProviderMock.request.mockResolvedValue({ | ||
data: { | ||
poaps: [], | ||
}, | ||
}); | ||
|
||
// When | ||
await poapsClient.fetch({ | ||
limit: 1, | ||
offset: 0, | ||
filterZeroAddress: false, | ||
}); | ||
|
||
// Then | ||
expect(compassProviderMock.request).toHaveBeenCalledWith(anyString(), { | ||
limit: 1, | ||
offset: 0, | ||
orderBy: {}, | ||
where: { | ||
collector_address: { | ||
_neq: '0x000000000000000000000000000000000000dead', | ||
}, | ||
}, | ||
}); | ||
}); | ||
|
||
it('request all tokens except zero address but include dead address when filter is given on false', async () => { | ||
// Given | ||
compassProviderMock.request.mockResolvedValue({ | ||
data: { | ||
poaps: [], | ||
}, | ||
}); | ||
|
||
// When | ||
await poapsClient.fetch({ | ||
limit: 1, | ||
offset: 0, | ||
filterDeadAddress: false, | ||
}); | ||
|
||
// Then | ||
expect(compassProviderMock.request).toHaveBeenCalledWith(anyString(), { | ||
limit: 1, | ||
offset: 0, | ||
orderBy: {}, | ||
where: { | ||
collector_address: { | ||
_neq: '0x0000000000000000000000000000000000000000', | ||
}, | ||
}, | ||
}); | ||
}); | ||
|
||
it('request tokens for collector when collectorAddress filter is given', async () => { | ||
// Given | ||
compassProviderMock.request.mockResolvedValue({ | ||
data: { | ||
poaps: [], | ||
}, | ||
}); | ||
|
||
// When | ||
await poapsClient.fetch({ | ||
limit: 1, | ||
offset: 0, | ||
collectorAddress: '0xf6b6f07862a02c85628b3a9688beae07fea9c863', | ||
}); | ||
|
||
// Then | ||
expect(compassProviderMock.request).toHaveBeenCalledWith(anyString(), { | ||
limit: 1, | ||
offset: 0, | ||
orderBy: {}, | ||
where: { | ||
collector_address: { | ||
_eq: '0xf6b6f07862a02c85628b3a9688beae07fea9c863', | ||
}, | ||
}, | ||
}); | ||
}); | ||
|
||
it('request tokens for collector when collectorAddress filter is given without null address filter even when given', async () => { | ||
// Given | ||
compassProviderMock.request.mockResolvedValue({ | ||
data: { | ||
poaps: [], | ||
}, | ||
}); | ||
|
||
// When | ||
await poapsClient.fetch({ | ||
limit: 1, | ||
offset: 0, | ||
collectorAddress: '0xf6b6f07862a02c85628b3a9688beae07fea9c863', | ||
filterZeroAddress: true, | ||
filterDeadAddress: true, | ||
}); | ||
|
||
// Then | ||
expect(compassProviderMock.request).toHaveBeenCalledWith(anyString(), { | ||
limit: 1, | ||
offset: 0, | ||
orderBy: {}, | ||
where: { | ||
collector_address: { | ||
_eq: '0xf6b6f07862a02c85628b3a9688beae07fea9c863', | ||
}, | ||
}, | ||
}); | ||
}); | ||
}); | ||
}); |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -884,8 +884,8 @@ __metadata: | |
version: 0.0.0-use.local | ||
resolution: "@poap-xyz/drops@workspace:packages/drops" | ||
dependencies: | ||
"@poap-xyz/providers": 0.2.1 | ||
"@poap-xyz/utils": 0.2.1 | ||
"@poap-xyz/providers": 0.2.2 | ||
"@poap-xyz/utils": 0.2.2 | ||
languageName: unknown | ||
linkType: soft | ||
|
||
|
@@ -901,8 +901,8 @@ __metadata: | |
version: 0.0.0-use.local | ||
resolution: "@poap-xyz/moments@workspace:packages/moments" | ||
dependencies: | ||
"@poap-xyz/providers": 0.2.1 | ||
"@poap-xyz/utils": 0.2.1 | ||
"@poap-xyz/providers": 0.2.2 | ||
"@poap-xyz/utils": 0.2.2 | ||
"@types/uuid": ^9.0.2 | ||
uuid: ^9.0.0 | ||
languageName: unknown | ||
|
@@ -912,22 +912,22 @@ __metadata: | |
version: 0.0.0-use.local | ||
resolution: "@poap-xyz/poaps@workspace:packages/poaps" | ||
dependencies: | ||
"@poap-xyz/providers": 0.2.1 | ||
"@poap-xyz/utils": 0.2.1 | ||
"@poap-xyz/providers": 0.2.2 | ||
"@poap-xyz/utils": 0.2.2 | ||
languageName: unknown | ||
linkType: soft | ||
|
||
"@poap-xyz/providers@*, @poap-xyz/[email protected].1, @poap-xyz/providers@workspace:packages/providers": | ||
"@poap-xyz/providers@*, @poap-xyz/[email protected].2, @poap-xyz/providers@workspace:packages/providers": | ||
version: 0.0.0-use.local | ||
resolution: "@poap-xyz/providers@workspace:packages/providers" | ||
dependencies: | ||
"@poap-xyz/utils": 0.2.1 | ||
"@poap-xyz/utils": 0.2.2 | ||
axios: ^1.3.5 | ||
axios-mock-adapter: ^1.21.4 | ||
languageName: unknown | ||
linkType: soft | ||
|
||
"@poap-xyz/utils@*, @poap-xyz/[email protected].1, @poap-xyz/utils@workspace:packages/utils": | ||
"@poap-xyz/utils@*, @poap-xyz/[email protected].2, @poap-xyz/utils@workspace:packages/utils": | ||
version: 0.0.0-use.local | ||
resolution: "@poap-xyz/utils@workspace:packages/utils" | ||
languageName: unknown | ||
|