-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #466 from GatherPress/mauteri-updates-4
Added tests for EditCover component.
- Loading branch information
Showing
8 changed files
with
129 additions
and
8 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
<?php return array('dependencies' => array('moment', 'react', 'wp-api-fetch', 'wp-block-editor', 'wp-blocks', 'wp-components', 'wp-data', 'wp-element', 'wp-i18n'), 'version' => '8021becf5cd361aaca25'); | ||
<?php return array('dependencies' => array('moment', 'react', 'wp-api-fetch', 'wp-block-editor', 'wp-blocks', 'wp-components', 'wp-data', 'wp-element', 'wp-i18n'), 'version' => '13b88270358cb87aa9cd'); |
Large diffs are not rendered by default.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
<?php return array('dependencies' => array('react', 'wp-components', 'wp-data', 'wp-dom-ready', 'wp-element', 'wp-i18n'), 'version' => '11e7b54272b76b0ed446'); | ||
<?php return array('dependencies' => array('react', 'wp-components', 'wp-data', 'wp-dom-ready', 'wp-element', 'wp-i18n'), 'version' => '3291e30a443c794afab6'); |
Large diffs are not rendered by default.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
/** | ||
* External dependencies. | ||
*/ | ||
import { render } from '@testing-library/react'; | ||
import { expect, test } from '@jest/globals'; | ||
import '@testing-library/jest-dom'; | ||
|
||
/** | ||
* Internal dependencies. | ||
*/ | ||
import EditCover from '../../../../../src/components/EditCover'; | ||
|
||
/** | ||
* Coverage for EditCover. | ||
*/ | ||
test('EditCover is display block by default', () => { | ||
const { container } = render(<EditCover />); | ||
|
||
expect(container.children[0]).toHaveStyle('position: relative'); | ||
expect(container.children[0].children[0]).toHaveStyle('display: block'); | ||
}); | ||
|
||
test('EditCover is display block when isSelected is false', () => { | ||
const { container } = render(<EditCover isSelected={false} />); | ||
|
||
expect(container.children[0]).toHaveStyle('position: relative'); | ||
expect(container.children[0].children[0]).toHaveStyle('display: block'); | ||
}); | ||
|
||
test('EditCover is display none when isSelected is true', () => { | ||
const { container } = render(<EditCover isSelected={true} />); | ||
|
||
expect(container.children[0]).toHaveStyle('position: relative'); | ||
expect(container.children[0].children[0]).toHaveStyle('display: none'); | ||
}); |
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,59 @@ | ||
/** | ||
* External dependencies. | ||
*/ | ||
import { render } from '@testing-library/react'; | ||
import { expect, test } from '@jest/globals'; | ||
import '@testing-library/jest-dom'; | ||
|
||
/** | ||
* Internal dependencies. | ||
*/ | ||
import MapEmbed from '../../../../../src/components/MapEmbed'; | ||
|
||
/** | ||
* Coverage for MapEmbed. | ||
*/ | ||
test('MapEmbed returns empty when no location is provided', () => { | ||
const { container } = render(<MapEmbed />); | ||
|
||
expect(container).toBeEmptyDOMElement(); | ||
}); | ||
|
||
test('MapEmbed returns address in source when location is set', () => { | ||
const { container } = render( | ||
<MapEmbed location="50 South Fullerton Avenue, Montclair, NJ 07042" /> | ||
); | ||
|
||
expect(container.children[0].getAttribute('src')).toContain( | ||
'?q=50+South+Fullerton+Avenue%2C+Montclair%2C+NJ+07042' | ||
); | ||
expect(container.children[0].getAttribute('src')).toContain('&z=10'); | ||
expect(container.children[0].getAttribute('src')).toContain('&t=m'); | ||
expect(container.children[0].getAttribute('src')).toContain( | ||
'&output=embed' | ||
); | ||
expect(container.children[0]).toHaveStyle( | ||
'border: 0px; height: 300px; width: 100%;' | ||
); | ||
}); | ||
|
||
test('MapEmbed returns address in source when location, zoom, map type, height, and class are set', () => { | ||
const { container } = render( | ||
<MapEmbed | ||
location="50 South Fullerton Avenue, Montclair, NJ 07042" | ||
zoom={20} | ||
type="k" | ||
className="unit-test" | ||
height={100} | ||
/> | ||
); | ||
expect(container.children[0].getAttribute('src')).toContain( | ||
'q=50+South+Fullerton+Avenue%2C+Montclair%2C+NJ+07042' | ||
); | ||
expect(container.children[0].getAttribute('src')).toContain('&z=20'); | ||
expect(container.children[0].getAttribute('src')).toContain('&t=k'); | ||
expect(container.children[0]).toHaveStyle( | ||
'border: 0px; height: 100px; width: 100%;' | ||
); | ||
expect(container.children[0]).toHaveClass('unit-test'); | ||
}); |