Skip to content

Commit

Permalink
fix: Types and tests
Browse files Browse the repository at this point in the history
  • Loading branch information
LautaroPetaccio committed Jul 12, 2024
1 parent 8e12010 commit 4e897c6
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 21 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -158,4 +158,4 @@
"decentraland-ecs": "6.12.4-7784644013.commit-f770b3e",
"decentraland": "3.3.0"
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -1005,7 +1005,7 @@ export default class CreateSingleItemModal extends React.PureComponent<Props, St
const isSmartWearable = isSmart({ type, contents: this.state.contents })
const isRequirementMet = required.every(prop => prop !== undefined)

if (belongsToAThirdPartyV2Collection && !this.isMappingValid(mapping)) {
if ((belongsToAThirdPartyV2Collection && !mapping) || (belongsToAThirdPartyV2Collection && mapping && !this.isMappingValid(mapping))) {
return false
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { Dispatch } from 'redux'
import { ModalProps } from 'decentraland-dapps/dist/providers/ModalProvider/ModalProvider.types'
import { IPreviewController, Rarity } from '@dcl/schemas'
import { IPreviewController, Mapping, Rarity } from '@dcl/schemas'
import { Metrics } from 'modules/models/types'
import { Collection } from 'modules/collection/types'
import { saveItemRequest, SaveItemRequestAction } from 'modules/item/actions'
import { BodyShapeType, Item, ItemType, Mapping, SyncStatus } from 'modules/item/types'
import { BodyShapeType, Item, ItemType, SyncStatus } from 'modules/item/types'

export enum CreateItemView {
IMPORT = 'import',
Expand Down
6 changes: 4 additions & 2 deletions src/lib/api/transformations.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,8 @@ describe('when converting a RemoteItem into an Item', () => {
is_approved: true,
in_catalyst: true,
created_at: now,
updated_at: now
updated_at: now,
mappings: null
}

item = {
Expand Down Expand Up @@ -98,7 +99,8 @@ describe('when converting a RemoteItem into an Item', () => {
isApproved: true,
inCatalyst: true,
createdAt: now,
updatedAt: now
updatedAt: now,
mappings: null
}
})

Expand Down
3 changes: 2 additions & 1 deletion src/lib/api/transformations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ export function fromRemoteItem(remoteItem: RemoteItem): Item {
catalystContentHash: remoteItem.catalyst_content_hash,
metrics: remoteItem.metrics,
createdAt: +new Date(remoteItem.created_at),
updatedAt: +new Date(remoteItem.created_at)
updatedAt: +new Date(remoteItem.created_at),
mappings: remoteItem.mappings
}

if (remoteItem.collection_id) item.collectionId = remoteItem.collection_id
Expand Down
11 changes: 0 additions & 11 deletions src/modules/collection/utils.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -147,17 +147,6 @@ describe('when getting the collection type', () => {
expect(getCollectionType(collection)).toBe(CollectionType.THIRD_PARTY)
})
})

describe('when the collection has a third party v2 URN', () => {
beforeEach(() => {
jest.spyOn(dappsEth, 'getChainIdByNetwork').mockReturnValueOnce(ChainId.MATIC_MAINNET)
collection = { id: 'aCollection', urn: buildThirdPartyURN('thirdpartyname', 'collection-id', '22') } as Collection
})

it('should return a third party v2 collection type', () => {
expect(getCollectionType(collection)).toBe(CollectionType.THIRD_PARTY_V2)
})
})
})

describe('when checking if a collection is of type third party', () => {
Expand Down
9 changes: 6 additions & 3 deletions src/specs/item.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ export const mockedItem: Item = {
replaces: [WearableCategory.HELMET],
hides: [WearableCategory.HAIR],
tags: ['aHat']
}
},
mappings: null
}

export const mockedLocalItem: LocalItem = {
Expand Down Expand Up @@ -77,7 +78,8 @@ export const mockedLocalItem: LocalItem = {
replaces: [LocalItemWearableCategory.HELMET],
hides: [LocalItemWearableCategory.HAIR],
tags: ['aHat']
}
},
mappings: null
}

export const mockedRemoteItem: RemoteItem = {
Expand Down Expand Up @@ -125,7 +127,8 @@ export const mockedRemoteItem: RemoteItem = {
created_at: 0,
updated_at: 0,
local_content_hash: 'someHash',
catalyst_content_hash: null
catalyst_content_hash: null,
mappings: null
}

export const mockedItemContents = { 'anItemContent.glb': new Blob(), 'thumbnail.png': new Blob() }

0 comments on commit 4e897c6

Please sign in to comment.