import React from 'react' import { render, screen } from '@testing-library/react' import ButtonBuy, { ButtonBuyProps } from './' const downloadProps: ButtonBuyProps = { action: 'download', disabled: false, hasPreviousOrder: false, hasDatatoken: false, btSymbol: 'btSymbol', dtSymbol: 'dtSymbol', dtBalance: '100000000000', assetTimeout: '1 day', assetType: 'Dataset', stepText: 'TEST', priceType: 'fixed', isConsumable: true, isBalanceSufficient: true, consumableFeedback: 'TEST: consumableFeedback' } const computeProps: ButtonBuyProps = { action: 'compute', disabled: false, hasPreviousOrder: false, hasDatatoken: false, btSymbol: 'btSymbol', dtSymbol: 'dtSymbol', dtBalance: '100000000000', assetTimeout: '1 day', assetType: 'algorithm', hasPreviousOrderSelectedComputeAsset: false, hasDatatokenSelectedComputeAsset: false, dtSymbolSelectedComputeAsset: 'dtSymbol', dtBalanceSelectedComputeAsset: 'dtBalance', selectedComputeAssetType: 'selectedComputeAssetType', stepText: ' ', isLoading: false, type: 'submit', priceType: 'fixed', algorithmPriceType: 'free', isBalanceSufficient: true, isConsumable: true, consumableFeedback: 'consumableFeedback', isAlgorithmConsumable: true, hasProviderFee: false, retry: false } describe('Asset/AssetActions/ButtonBuy', () => { // TESTS FOR LOADING it('Renders Buy button without crashing', () => { render() const button = screen.getByText('TEST') expect(button).toContainHTML(' { render() const button = screen.getByText('Buy for 1 day') expect(button).toContainHTML(' { render() const button = screen.getByText('Download') expect(button).toContainHTML(' { render() const button = screen.getByText('Retry') expect(button).toContainHTML(' { render() const button = screen.getByText('Download') expect(button).toContainHTML(' { render() const button = screen.getByText('Get') expect(button).toContainHTML(' { render( ) const button = screen.getByText('Buy') expect(button).toContainHTML(' { render() const button = screen.getByText('Buy Compute Job') expect(button).toContainHTML(' { render() expect( screen.getByText( 'To use this algorithm, you will buy 1 dtSymbol and immediately send it back to the publisher. Connect to the correct network to interact with this asset. The C2D resources required to start the job are available, no payment is required for them. Please note that network gas fees still apply, even when using free assets.' ) ).toBeInTheDocument() }) it('Renders correct message for free compute asset with free algorithm', () => { render() expect( screen.getByText( 'This algorithm is free to use. Connect to the correct network to interact with this asset. The C2D resources required to start the job are available, no payment is required for them. Please note that network gas fees still apply, even when using free assets.' ) ).toBeInTheDocument() }) it('Renders correct message for free compute asset with free algorithm', () => { render() expect( screen.getByText( 'To use this algorithm, you will buy 1 dtSymbol and immediately send it back to the publisher. Connect to the correct network to interact with this asset. The C2D resources required to start the job are available, no payment is required for them.' ) ).toBeInTheDocument() }) it('Renders "Buy Compute Job" button for compute without crashing', () => { render() const button = screen.getByText('Buy Compute Job') expect(button).toContainHTML(' { render( ) const button = screen.getByText('Start Compute Job') expect(button).toContainHTML(' { render() const button = screen.getByText('Order Compute Job') expect(button).toContainHTML(' { render() const button = screen.getByText('Order Compute Job') expect(button).toContainHTML(' { render() const button = screen.getByText('Retry') expect(button).toContainHTML('