@@ -11,6 +11,7 @@ import '@testing-library/jest-dom';
11
11
import {
12
12
getVimeoURLParams ,
13
13
getYouTubeParams ,
14
+ isYouTubeNoCookie ,
14
15
} from '../src/plugins/video/lg-video-utils' ;
15
16
import utils from '../src/lg-utils' ;
16
17
import { VideoInfo } from '../src/types' ;
@@ -136,7 +137,7 @@ describe('Vimeo Video', () => {
136
137
137
138
describe ( 'YouTube Video' , ( ) => {
138
139
it ( 'should build player params' , async ( ) => {
139
- const url = '=" //www.youtube.com/watch?v=EIUJfXk3_3w' ;
140
+ const url = '//www.youtube.com/watch?v=EIUJfXk3_3w' ;
140
141
const videoInfo = utils . isVideo ( url , false , 0 ) ;
141
142
const settingParam = {
142
143
color : 'red' ,
@@ -148,7 +149,7 @@ describe('YouTube Video', () => {
148
149
) ;
149
150
} ) ;
150
151
it ( 'should override default params with src parmas' , async ( ) => {
151
- const url = '=" //www.youtube.com/watch?v=EIUJfXk3_3w&mute=0' ;
152
+ const url = '//www.youtube.com/watch?v=EIUJfXk3_3w&mute=0' ;
152
153
const videoInfo = utils . isVideo ( url , false , 0 ) ;
153
154
const settingParam = {
154
155
color : 'red' ,
@@ -160,21 +161,21 @@ describe('YouTube Video', () => {
160
161
) ;
161
162
} ) ;
162
163
it ( 'should work if settingsParams not provided' , async ( ) => {
163
- const url = '=" //www.youtube.com/watch?v=EIUJfXk3_3w&mute=0' ;
164
+ const url = '//www.youtube.com/watch?v=EIUJfXk3_3w&mute=0' ;
164
165
const videoInfo = utils . isVideo ( url , false , 0 ) ;
165
166
const settingParam = false ;
166
167
const params = getYouTubeParams ( videoInfo as VideoInfo , settingParam ) ;
167
168
expect ( params ) . toBe ( '?wmode=opaque&autoplay=0&mute=0&enablejsapi=1' ) ;
168
169
} ) ;
169
170
it ( 'should work if settingsParams and src params not provided' , async ( ) => {
170
- const url = '=" //www.youtube.com/watch?v=EIUJfXk3_3w' ;
171
+ const url = '//www.youtube.com/watch?v=EIUJfXk3_3w' ;
171
172
const videoInfo = utils . isVideo ( url , false , 0 ) ;
172
173
const settingParam = false ;
173
174
const params = getYouTubeParams ( videoInfo as VideoInfo , settingParam ) ;
174
175
expect ( params ) . toBe ( '?wmode=opaque&autoplay=0&mute=1&enablejsapi=1' ) ;
175
176
} ) ;
176
177
it ( 'should override default params with settings params' , async ( ) => {
177
- const url = '=" //www.youtube.com/watch?v=EIUJfXk3_3w' ;
178
+ const url = '//www.youtube.com/watch?v=EIUJfXk3_3w' ;
178
179
const videoInfo = utils . isVideo ( url , false , 0 ) ;
179
180
const settingParam = {
180
181
autoplay : 1 ,
@@ -184,7 +185,7 @@ describe('YouTube Video', () => {
184
185
expect ( params ) . toBe ( '?wmode=opaque&autoplay=1&mute=0&enablejsapi=1' ) ;
185
186
} ) ;
186
187
it ( 'should override settings params with src params' , async ( ) => {
187
- const url = '=" //www.youtube.com/watch?v=EIUJfXk3_3w&mute=0&color=red' ;
188
+ const url = '//www.youtube.com/watch?v=EIUJfXk3_3w&mute=0&color=red' ;
188
189
const videoInfo = utils . isVideo ( url , false , 0 ) ;
189
190
const settingParam = {
190
191
autoplay : 1 ,
@@ -195,4 +196,16 @@ describe('YouTube Video', () => {
195
196
'?wmode=opaque&autoplay=1&mute=0&enablejsapi=1&color=red' ,
196
197
) ;
197
198
} ) ;
199
+
200
+ it ( 'should detect as no-cookie url' , async ( ) => {
201
+ const url = 'https://www.youtube-nocookie.com/embed/r87A-Ql2czg' ;
202
+ const isYouTubeNoCookieURL = isYouTubeNoCookie ( url ) ;
203
+ expect ( isYouTubeNoCookieURL ) . toBeTruthy ( ) ;
204
+ } ) ;
205
+
206
+ it ( 'should detect as normal youtube url' , async ( ) => {
207
+ const url = '//www.youtube.com/watch?v=EIUJfXk3_3w&mute=0&color=red' ;
208
+ const isYouTubeNoCookieURL = isYouTubeNoCookie ( url ) ;
209
+ expect ( isYouTubeNoCookieURL ) . toBeFalsy ( ) ;
210
+ } ) ;
198
211
} ) ;
0 commit comments