Skip to content

Commit c6869a9

Browse files
committed
Test removal of <p> tag
1 parent 30d174d commit c6869a9

File tree

1 file changed

+26
-16
lines changed

1 file changed

+26
-16
lines changed

tests/php/test-amp-facebook-embed.php

Lines changed: 26 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -63,17 +63,17 @@ public function test__get_scripts( $source, $expected ) {
6363
*/
6464
public function get_raw_embed_dataset() {
6565
return [
66-
'no_embed_blockquote' => [
66+
'no_embed_blockquote' => [
6767
'<p>Hello world.</p>',
6868
'<p>Hello world.</p>',
6969
],
7070

71-
'div_without_facebook_embed' => [
71+
'div_without_facebook_embed' => [
7272
'<div>lorem ipsum</div>',
7373
'<div>lorem ipsum</div>',
7474
],
7575

76-
'simple_url_https' => [
76+
'simple_url_https' => [
7777
'https://www.facebook.com/zuck/posts/10102593740125791' . PHP_EOL,
7878
'
7979
<amp-facebook width="500" height="400" data-href="https://www.facebook.com/zuck/posts/10102593740125791" data-embed-as="post" layout="responsive">
@@ -86,7 +86,7 @@ public function get_raw_embed_dataset() {
8686
' . PHP_EOL,
8787
],
8888

89-
'notes_url' => [
89+
'notes_url' => [
9090
'https://www.facebook.com/notes/facebook-engineering/under-the-hood-the-javascript-sdk-truly-asynchronous-loading/10151176218703920/' . PHP_EOL,
9191
'
9292
<amp-facebook width="500" height="400" data-href="https://www.facebook.com/notes/facebook-engineering/under-the-hood-the-javascript-sdk-truly-asynchronous-loading/10151176218703920/" data-embed-as="post" layout="responsive">
@@ -97,7 +97,7 @@ public function get_raw_embed_dataset() {
9797
' . PHP_EOL,
9898
],
9999

100-
'photo_url' => [
100+
'photo_url' => [
101101
'https://www.facebook.com/photo.php?fbid=10102533316889441&set=a.529237706231.2034669.4&type=3&theater' . PHP_EOL,
102102
'
103103
<amp-facebook width="500" height="400" data-href="https://www.facebook.com/photo.php?fbid=10102533316889441&amp;set=a.529237706231.2034669.4&amp;type=3&amp;theater" data-embed-as="post" layout="responsive">
@@ -109,7 +109,7 @@ public function get_raw_embed_dataset() {
109109
' . PHP_EOL,
110110
],
111111

112-
'video_url' => [
112+
'video_url' => [
113113
'https://www.facebook.com/zuck/videos/10102509264909801/' . PHP_EOL,
114114
'
115115
<amp-facebook width="500" height="400" data-href="https://www.facebook.com/zuck/videos/10102509264909801/" data-embed-as="video" layout="responsive">
@@ -130,12 +130,12 @@ public function get_raw_embed_dataset() {
130130
' . PHP_EOL,
131131
],
132132

133-
'post_embed' => [
133+
'post_embed' => [
134134
'<div class="fb-post" data-href="https://www.facebook.com/notes/facebook-engineering/under-the-hood-the-javascript-sdk-truly-asynchronous-loading/10151176218703920/"></div>',
135135
'<amp-facebook width="600" height="400" data-href="https://www.facebook.com/notes/facebook-engineering/under-the-hood-the-javascript-sdk-truly-asynchronous-loading/10151176218703920/" data-embed-as="post" layout="responsive"></amp-facebook>',
136136
],
137137

138-
'post_with_fallbacks' => [
138+
'post_with_fallbacks' => [
139139
'
140140
<div class="fb-post" data-href="https://www.facebook.com/20531316728/posts/10154009990506729/" data-width="500" data-show-text="true">
141141
<blockquote cite="https://developers.facebook.com/20531316728/posts/10154009990506729/" class="fb-xfbml-parse-ignore">
@@ -152,12 +152,12 @@ public function get_raw_embed_dataset() {
152152
',
153153
],
154154

155-
'video_embed' => [
155+
'video_embed' => [
156156
'<div class="fb-video" data-href="https://www.facebook.com/amanda.orr.56/videos/10212156330049017/" data-show-text="false"></div>',
157157
'<amp-facebook width="600" height="400" data-href="https://www.facebook.com/amanda.orr.56/videos/10212156330049017/" data-show-text="false" data-embed-as="video" layout="responsive"></amp-facebook>',
158158
],
159159

160-
'page_embed' => [
160+
'page_embed' => [
161161
'
162162
<div class="fb-page" data-href="https://www.facebook.com/xwp.co/" data-width="340" data-height="432" data-hide-cover="true" data-show-facepile="true" data-show-posts="false">
163163
<div class="fb-xfbml-parse-ignore">
@@ -176,7 +176,7 @@ public function get_raw_embed_dataset() {
176176
',
177177
],
178178

179-
'like' => [
179+
'like' => [
180180
'
181181
<div class="fb-like" data-href="https://developers.facebook.com/docs/plugins/" data-width="400" data-layout="standard" data-action="like" data-size="small" data-show-faces="true" data-share="true"></div>
182182
',
@@ -186,38 +186,48 @@ public function get_raw_embed_dataset() {
186186
',
187187
],
188188

189-
'comments' => [
189+
'comments' => [
190190
'
191191
<div class="fb-comments" data-href="https://developers.facebook.com/docs/plugins/comments#configurator" data-numposts="5"></div>
192192
',
193193
'<amp-facebook-comments width="600" height="400" data-href="https://developers.facebook.com/docs/plugins/comments#configurator" data-numposts="5" layout="responsive"></amp-facebook-comments>',
194194
],
195195

196-
'comments_full_width' => [
196+
'comments_full_width' => [
197197
'
198198
<div class="fb-comments" data-href="https://developers.facebook.com/docs/plugins/comments#configurator" data-width="100%" data-numposts="5"></div>
199199
',
200200
'<amp-facebook-comments width="auto" height="400" data-href="https://developers.facebook.com/docs/plugins/comments#configurator" data-numposts="5" layout="fixed-height"></amp-facebook-comments>',
201201
],
202202

203-
'comments_full_width_2' => [
203+
'comments_full_width_2' => [
204204
'
205205
<div class="fb-comments" data-href="https://developers.facebook.com/docs/plugins/comments#configurator" data-height="123" data-width="100%" data-numposts="5"></div>
206206
',
207207
'<amp-facebook-comments width="auto" height="123" data-href="https://developers.facebook.com/docs/plugins/comments#configurator" data-numposts="5" layout="fixed-height"></amp-facebook-comments>',
208208
],
209209

210-
'comment_embed' => [
210+
'comment_embed' => [
211211
'
212212
<div class="fb-comment-embed" data-href="https://www.facebook.com/zuck/posts/10102735452532991?comment_id=1070233703036185" data-width="500"></div>
213213
',
214214
'<amp-facebook width="500" height="400" data-href="https://www.facebook.com/zuck/posts/10102735452532991?comment_id=1070233703036185" data-embed-as="comment" layout="responsive"></amp-facebook>',
215215
],
216216

217-
'remove_fb_root' => [
217+
'remove_fb_root' => [
218218
'<div id="fb-root"></div>' . str_repeat( '<script async defer crossorigin="anonymous" src="https://connect.facebook.net/en_US/sdk.js#xfbml=1&version=v3.2"></script>', 5 ), // phpcs:ignore WordPress.WP.EnqueuedResources.NonEnqueuedScript
219219
'',
220220
],
221+
222+
'remove_empty_p_tag' => [
223+
'<p><script async defer crossorigin="anonymous" src="https://connect.facebook.net/en_US/sdk.js#xfbml=1&version=v3.2"></script></p><div id="fb-root"></div>', // phpcs:ignore WordPress.WP.EnqueuedResources.NonEnqueuedScript
224+
'',
225+
],
226+
227+
'keep_p_tag_if_it_has_children' => [
228+
'<p><span id="foo-bar"></span><script async defer crossorigin="anonymous" src="https://connect.facebook.net/en_US/sdk.js#xfbml=1&version=v3.2"></script></p><div id="fb-root"></div>', // phpcs:ignore WordPress.WP.EnqueuedResources.NonEnqueuedScript
229+
'<p><span id="foo-bar"></span></p>',
230+
],
221231
];
222232
}
223233

0 commit comments

Comments
 (0)