-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Tip component when assets are imported
- Loading branch information
Showing
5 changed files
with
101 additions
and
1 deletion.
There are no files selected for viewing
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
66 changes: 66 additions & 0 deletions
66
js/src/components/paid-ads/asset-group/asset-group-section.test.js
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,66 @@ | ||
jest.mock( '.~/components/adaptive-form', () => ( { | ||
useAdaptiveFormContext: jest | ||
.fn() | ||
.mockName( 'useAdaptiveFormContext' ) | ||
.mockImplementation( () => { | ||
return { | ||
adapter: { | ||
baseAssetGroup: { final_url: 'https://example.com' }, | ||
hasImportedAssets: false, | ||
isEmptyAssetEntityGroup: false, | ||
resetAssetGroup: jest.fn(), | ||
}, | ||
}; | ||
} ), | ||
} ) ); | ||
|
||
/** | ||
* External dependencies | ||
*/ | ||
import '@testing-library/jest-dom'; | ||
import { render } from '@testing-library/react'; | ||
|
||
/** | ||
* Internal dependencies | ||
*/ | ||
import AssetGroupSection from '.~/components/paid-ads/asset-group/asset-group-section'; | ||
import { useAdaptiveFormContext } from '.~/components/adaptive-form'; | ||
|
||
jest.mock( '.~/components/paid-ads/asset-group/asset-group-card', () => | ||
jest.fn( ( props ) => <div { ...props } /> ).mockName( 'AssetGroupCard' ) | ||
); | ||
|
||
describe( 'AssetGroupSection', () => { | ||
test( 'Component renders', () => { | ||
const { queryByText } = render( <AssetGroupSection /> ); | ||
expect( queryByText( /Add additional assets/i ) ).toBeInTheDocument(); | ||
} ); | ||
|
||
test( 'Component not showing Tip if there are no imported assets', () => { | ||
const { queryByText } = render( <AssetGroupSection /> ); | ||
expect( | ||
queryByText( | ||
'We auto-populated assets directly from your Final URL. We encourage you to edit or add more in order to best showcase your business.' | ||
) | ||
).not.toBeInTheDocument(); | ||
} ); | ||
|
||
test( 'Component showing Tip if there are imported assets', () => { | ||
useAdaptiveFormContext.mockImplementation( () => { | ||
return { | ||
adapter: { | ||
baseAssetGroup: { final_url: 'https://example.com' }, | ||
hasImportedAssets: true, | ||
isEmptyAssetEntityGroup: false, | ||
resetAssetGroup: jest.fn(), | ||
}, | ||
}; | ||
} ); | ||
const { queryByText } = render( <AssetGroupSection /> ); | ||
expect( | ||
queryByText( | ||
'We auto-populated assets directly from your Final URL. We encourage you to edit or add more in order to best showcase your business.' | ||
) | ||
).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