-
Notifications
You must be signed in to change notification settings - Fork 685
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Melisa Anabella Rossi
authored
Jul 9, 2024
1 parent
47b4d7d
commit 116f791
Showing
29 changed files
with
1,120 additions
and
188 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
76 changes: 76 additions & 0 deletions
76
webapp/src/components/AssetPage/SaleActionBox/ItemSaleActions/ItemSaleActions.spec.tsx
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,76 @@ | ||
import { t } from 'decentraland-dapps/dist/modules/translation' | ||
import { Wallet } from 'decentraland-dapps/dist/modules/wallet' | ||
import { Item } from '../../../../modules/item/types' | ||
import { renderWithProviders } from '../../../../utils/test' | ||
import ItemSaleActions from './ItemSaleActions' | ||
import { Props } from './ItemSaleActions.types' | ||
|
||
function renderItemSaleActions(props: Partial<Props> = {}) { | ||
return renderWithProviders( | ||
<ItemSaleActions | ||
item={{ id: 'dasd', available: 2, creator: '0xcreator' } as Item} | ||
wallet={{ address: '0xtest' } as Wallet} | ||
isBidsOffchainEnabled={false} | ||
onBuyWithCrypto={jest.fn()} | ||
{...props} | ||
/> | ||
) | ||
} | ||
|
||
let props: Partial<Props> = {} | ||
|
||
describe('when off chain bids are enabled', () => { | ||
beforeEach(() => { | ||
props = { ...props, isBidsOffchainEnabled: true } | ||
}) | ||
|
||
describe('and the user is not the creator of the item', () => { | ||
beforeEach(() => { | ||
props = { ...props, wallet: { address: '0xuser' } as Wallet, item: { id: '1', creator: '0xcreator' } as Item } | ||
}) | ||
|
||
describe('and slots available to mint', () => { | ||
beforeEach(() => { | ||
props = { ...props, item: { ...props.item, available: 2 } as Item } | ||
}) | ||
|
||
it('should render the bid button', () => { | ||
const { getByRole } = renderItemSaleActions(props) | ||
expect(getByRole('link', { name: t('asset_page.actions.place_bid') })).toBeInTheDocument() | ||
}) | ||
}) | ||
|
||
describe('and there are no slots available to mint', () => { | ||
beforeEach(() => { | ||
props = { ...props, item: { ...props.item, available: 0 } as Item } | ||
}) | ||
|
||
it('should not render the bid button', () => { | ||
const { queryByRole } = renderItemSaleActions(props) | ||
expect(queryByRole('link', { name: t('asset_page.actions.place_bid') })).not.toBeInTheDocument() | ||
}) | ||
}) | ||
}) | ||
|
||
describe('and the user is the creator of the item', () => { | ||
beforeEach(() => { | ||
props = { ...props, wallet: { address: '0xcreator' } as Wallet, item: { id: '1', creator: '0xcreator' } as Item } | ||
}) | ||
|
||
it('should not render the bid button', () => { | ||
const { queryByRole } = renderItemSaleActions(props) | ||
expect(queryByRole('link', { name: t('asset_page.actions.place_bid') })).not.toBeInTheDocument() | ||
}) | ||
}) | ||
}) | ||
|
||
describe('when off chain bids are disabled', () => { | ||
beforeEach(() => { | ||
props = { ...props, isBidsOffchainEnabled: false } | ||
}) | ||
|
||
it('should not render the bid button', () => { | ||
const { queryByRole } = renderItemSaleActions(props) | ||
expect(queryByRole('link', { name: t('asset_page.actions.place_bid') })).not.toBeInTheDocument() | ||
}) | ||
}) |
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.