-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(First Listed At): Support sorting by firstListedAt (#211)
* feat: Sort by first listed at * chore: Update commons * chore: Master package files * chore: Update commons * chore: Master package files * chore: Update commons * fix: Tests * chore: Master package files * chore: Update commons * chore: Test getCollectionsQuery * chore: Test fromCollectionFragment * chore: Test getItemQuery * chore: Test fromItemFragment * chore: Use SortDirection instead of strings
- Loading branch information
Showing
13 changed files
with
242 additions
and
27 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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
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,78 @@ | ||
import { ChainId, CollectionSortBy, Network } from '@dcl/schemas' | ||
import { CollectionFragment } from './types' | ||
import { fromCollectionFragment, getCollectionsQuery } from './utils' | ||
|
||
describe('#getCollectionsQuery', () => { | ||
describe('when sortBy is CollectionSortBy.RECENTLY_LISTED', () => { | ||
let query: string | ||
|
||
beforeEach(() => { | ||
query = getCollectionsQuery({ | ||
sortBy: CollectionSortBy.RECENTLY_LISTED, | ||
}) | ||
}) | ||
|
||
it('should add firstListedAt_not: null where filter', () => { | ||
expect(query.includes('firstListedAt_not: null')).toBeTruthy() | ||
}) | ||
|
||
it('should add firstListedAt as orderBy', () => { | ||
expect(query.includes('orderBy: firstListedAt')).toBeTruthy() | ||
}) | ||
|
||
it('should add desc as orderDirection', () => { | ||
expect(query.includes('orderDirection: desc')).toBeTruthy() | ||
}) | ||
}) | ||
}) | ||
|
||
describe('#fromCollectionFragment', () => { | ||
let collectionFragment: CollectionFragment | ||
|
||
beforeEach(() => { | ||
collectionFragment = { | ||
id: 'id', | ||
urn: 'urn', | ||
name: 'name', | ||
creator: 'creator', | ||
searchIsStoreMinter: false, | ||
itemsCount: 100, | ||
createdAt: '100', | ||
updatedAt: '200', | ||
reviewedAt: '300', | ||
firstListedAt: null, | ||
} | ||
}) | ||
|
||
describe('when fragment firstListedAt is null', () => { | ||
beforeEach(() => { | ||
collectionFragment.firstListedAt = null | ||
}) | ||
|
||
it('should return a Collection with firstListedAt as null', () => { | ||
const collection = fromCollectionFragment( | ||
collectionFragment, | ||
Network.MATIC, | ||
ChainId.MATIC_MUMBAI | ||
) | ||
|
||
expect(collection.firstListedAt).toBeNull() | ||
}) | ||
}) | ||
|
||
describe('when fragment firstListedAt is "100"', () => { | ||
beforeEach(() => { | ||
collectionFragment.firstListedAt = '100' | ||
}) | ||
|
||
it('should return a Collection with firstListedAt as 100000', () => { | ||
const collection = fromCollectionFragment( | ||
collectionFragment, | ||
Network.MATIC, | ||
ChainId.MATIC_MUMBAI | ||
) | ||
|
||
expect(collection.firstListedAt).toBe(100000) | ||
}) | ||
}) | ||
}) |
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
Oops, something went wrong.