• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

decentraland / marketplace / 9604252205

20 Jun 2024 08:55PM UTC coverage: 66.593% (+0.09%) from 66.499%
9604252205

push

github

web-flow
fix location error (#2263)

2606 of 5072 branches covered (51.38%)

Branch coverage included in aggregate %.

30 of 40 new or added lines in 7 files covered. (75.0%)

1 existing line in 1 file now uncovered.

7606 of 10263 relevant lines covered (74.11%)

77.63 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

83.33
/webapp/src/modules/item/selectors.ts
1
import { createMatchSelector } from 'connected-react-router'
41✔
2
import { AnyAction } from 'redux'
3
import { createSelector } from 'reselect'
41✔
4
import { Item } from '@dcl/schemas'
5
import { AuthorizationStepStatus } from 'decentraland-dapps/dist/containers/withAuthorizedAction/AuthorizationModal'
41✔
6
import { isLoadingType } from 'decentraland-dapps/dist/modules/loading/selectors'
41✔
7
import { RootState } from '../reducer'
8
import { locations } from '../routing/locations'
41✔
9
import {
10
  BUY_ITEM_REQUEST,
11
  FETCH_COLLECTION_ITEMS_REQUEST,
12
  FETCH_ITEM_REQUEST,
13
  FetchCollectionItemsRequestAction,
14
  FetchItemRequestAction
15
} from './actions'
41✔
16

17
const isFetchItemRequest = (action: AnyAction): action is FetchItemRequestAction => action.type === FETCH_ITEM_REQUEST
41✔
18
const isFetchCollectionItemsRequest = (action: AnyAction): action is FetchCollectionItemsRequestAction =>
41✔
19
  action.type === FETCH_COLLECTION_ITEMS_REQUEST
2✔
20

21
export const getState = (state: RootState) => state.item
253✔
22
export const getData = (state: RootState) => getState(state).data
266✔
23
export const getError = (state: RootState) => getState(state).error
41✔
24
export const getLoading = (state: RootState) => getState(state).loading
41✔
25

26
export const getMintItemStatus = (state: RootState) => {
41✔
27
  if (isLoadingType(getLoading(state), BUY_ITEM_REQUEST)) {
3✔
28
    return AuthorizationStepStatus.WAITING
1✔
29
  }
30

31
  if (getError(state)) {
2✔
32
    return AuthorizationStepStatus.ERROR
1✔
33
  }
34

35
  return AuthorizationStepStatus.PENDING
1✔
36
}
37

38
export const isFetchingItem = (state: RootState, contractAddress: string, tokenId: string) =>
41✔
39
  getLoading(state).find(
7✔
40
    action => isFetchItemRequest(action) && action.payload.contractAddress === contractAddress && action.payload.tokenId === tokenId
2✔
41
  ) !== undefined
42

43
export const isFetchingItemsOfCollection = (state: RootState, contractAddress: string) =>
41✔
44
  getLoading(state).find(action => isFetchCollectionItemsRequest(action) && action.payload.contractAddresses?.includes(contractAddress)) !==
29✔
45
  undefined
46

47
export const getItems = createSelector<RootState, ReturnType<typeof getData>, Item[]>(getData, itemsById => Object.values(itemsById))
41✔
48

49
const ItemDetailMatchSelector = createMatchSelector<
41✔
50
  RootState,
51
  {
52
    contractAddress: string
53
    tokenId: string
54
  }
55
>(locations.item(':contractAddress', ':tokenId'))
56

57
export const getContractAddress = createSelector<RootState, ReturnType<typeof ItemDetailMatchSelector>, string | null>(
41✔
58
  ItemDetailMatchSelector,
NEW
59
  match => match?.params.contractAddress.toLowerCase() || null
×
60
)
61

62
export const getTokenId = createSelector<RootState, ReturnType<typeof ItemDetailMatchSelector>, string | null>(
41✔
63
  ItemDetailMatchSelector,
64
  match => match?.params.tokenId || null
1✔
65
)
66

67
export const getItemsByContractAddress = createSelector(getItems, items =>
41✔
68
  items.reduce(
2✔
69
    (acc, item) => {
70
      const { contractAddress } = item
×
71
      if (!acc[contractAddress]) acc[contractAddress] = []
×
72
      acc[contractAddress].push(item)
×
73
      return acc
×
74
    },
75
    {} as Record<string, Item[]>
76
  )
77
)
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc