mirror of https://git.lenooby09.tech/LeNooby09/social-app.git
at no-pointer-events 767 lines 22 kB view raw
1import {RichText} from '@atproto/api' 2import { 3 makeRecordUri, 4 toNiceDomain, 5 toShortUrl, 6 toShareUrl, 7} from '../../src/lib/strings/url-helpers' 8import {pluralize, enforceLen} from '../../src/lib/strings/helpers' 9import {ago} from '../../src/lib/strings/time' 10import {detectLinkables} from '../../src/lib/strings/rich-text-detection' 11import {shortenLinks} from '../../src/lib/strings/rich-text-manip' 12import {makeValidHandle, createFullHandle} from '../../src/lib/strings/handles' 13import {cleanError} from '../../src/lib/strings/errors' 14import {parseEmbedPlayerFromUrl} from 'lib/strings/embed-player' 15 16describe('detectLinkables', () => { 17 const inputs = [ 18 'no linkable', 19 '@start middle end', 20 'start @middle end', 21 'start middle @end', 22 '@start @middle @end', 23 '@full123.test-of-chars', 24 'not@right', 25 '@bad!@#$chars', 26 '@newline1\n@newline2', 27 'parenthetical (@handle)', 28 'start https://middle.com end', 29 'start https://middle.com/foo/bar end', 30 'start https://middle.com/foo/bar?baz=bux end', 31 'start https://middle.com/foo/bar?baz=bux#hash end', 32 'https://start.com/foo/bar?baz=bux#hash middle end', 33 'start middle https://end.com/foo/bar?baz=bux#hash', 34 'https://newline1.com\nhttps://newline2.com', 35 'start middle.com end', 36 'start middle.com/foo/bar end', 37 'start middle.com/foo/bar?baz=bux end', 38 'start middle.com/foo/bar?baz=bux#hash end', 39 'start.com/foo/bar?baz=bux#hash middle end', 40 'start middle end.com/foo/bar?baz=bux#hash', 41 'newline1.com\nnewline2.com', 42 'not.. a..url ..here', 43 'e.g.', 44 'e.g. real.com fake.notreal', 45 'something-cool.jpg', 46 'website.com.jpg', 47 'e.g./foo', 48 'website.com.jpg/foo', 49 'Classic article https://socket3.wordpress.com/2018/02/03/designing-windows-95s-user-interface/', 50 'Classic article https://socket3.wordpress.com/2018/02/03/designing-windows-95s-user-interface/ ', 51 'https://foo.com https://bar.com/whatever https://baz.com', 52 'punctuation https://foo.com, https://bar.com/whatever; https://baz.com.', 53 'parenthetical (https://foo.com)', 54 'except for https://foo.com/thing_(cool)', 55 ] 56 const outputs = [ 57 ['no linkable'], 58 [{link: '@start'}, ' middle end'], 59 ['start ', {link: '@middle'}, ' end'], 60 ['start middle ', {link: '@end'}], 61 [{link: '@start'}, ' ', {link: '@middle'}, ' ', {link: '@end'}], 62 [{link: '@full123.test-of-chars'}], 63 ['not@right'], 64 [{link: '@bad'}, '!@#$chars'], 65 [{link: '@newline1'}, '\n', {link: '@newline2'}], 66 ['parenthetical (', {link: '@handle'}, ')'], 67 ['start ', {link: 'https://middle.com'}, ' end'], 68 ['start ', {link: 'https://middle.com/foo/bar'}, ' end'], 69 ['start ', {link: 'https://middle.com/foo/bar?baz=bux'}, ' end'], 70 ['start ', {link: 'https://middle.com/foo/bar?baz=bux#hash'}, ' end'], 71 [{link: 'https://start.com/foo/bar?baz=bux#hash'}, ' middle end'], 72 ['start middle ', {link: 'https://end.com/foo/bar?baz=bux#hash'}], 73 [{link: 'https://newline1.com'}, '\n', {link: 'https://newline2.com'}], 74 ['start ', {link: 'middle.com'}, ' end'], 75 ['start ', {link: 'middle.com/foo/bar'}, ' end'], 76 ['start ', {link: 'middle.com/foo/bar?baz=bux'}, ' end'], 77 ['start ', {link: 'middle.com/foo/bar?baz=bux#hash'}, ' end'], 78 [{link: 'start.com/foo/bar?baz=bux#hash'}, ' middle end'], 79 ['start middle ', {link: 'end.com/foo/bar?baz=bux#hash'}], 80 [{link: 'newline1.com'}, '\n', {link: 'newline2.com'}], 81 ['not.. a..url ..here'], 82 ['e.g.'], 83 ['e.g. ', {link: 'real.com'}, ' fake.notreal'], 84 ['something-cool.jpg'], 85 ['website.com.jpg'], 86 ['e.g./foo'], 87 ['website.com.jpg/foo'], 88 [ 89 'Classic article ', 90 { 91 link: 'https://socket3.wordpress.com/2018/02/03/designing-windows-95s-user-interface/', 92 }, 93 ], 94 [ 95 'Classic article ', 96 { 97 link: 'https://socket3.wordpress.com/2018/02/03/designing-windows-95s-user-interface/', 98 }, 99 ' ', 100 ], 101 [ 102 {link: 'https://foo.com'}, 103 ' ', 104 {link: 'https://bar.com/whatever'}, 105 ' ', 106 {link: 'https://baz.com'}, 107 ], 108 [ 109 'punctuation ', 110 {link: 'https://foo.com'}, 111 ', ', 112 {link: 'https://bar.com/whatever'}, 113 '; ', 114 {link: 'https://baz.com'}, 115 '.', 116 ], 117 ['parenthetical (', {link: 'https://foo.com'}, ')'], 118 ['except for ', {link: 'https://foo.com/thing_(cool)'}], 119 ] 120 it('correctly handles a set of text inputs', () => { 121 for (let i = 0; i < inputs.length; i++) { 122 const input = inputs[i] 123 const output = detectLinkables(input) 124 expect(output).toEqual(outputs[i]) 125 } 126 }) 127}) 128 129describe('pluralize', () => { 130 const inputs: [number, string, string?][] = [ 131 [1, 'follower'], 132 [1, 'member'], 133 [100, 'post'], 134 [1000, 'repost'], 135 [10000, 'upvote'], 136 [100000, 'other'], 137 [2, 'man', 'men'], 138 ] 139 const outputs = [ 140 'follower', 141 'member', 142 'posts', 143 'reposts', 144 'upvotes', 145 'others', 146 'men', 147 ] 148 149 it('correctly pluralizes a set of words', () => { 150 for (let i = 0; i < inputs.length; i++) { 151 const input = inputs[i] 152 const output = pluralize(...input) 153 expect(output).toEqual(outputs[i]) 154 } 155 }) 156}) 157 158describe('makeRecordUri', () => { 159 const inputs: [string, string, string][] = [ 160 ['alice.test', 'app.bsky.feed.post', '3jk7x4irgv52r'], 161 ] 162 const outputs = ['at://alice.test/app.bsky.feed.post/3jk7x4irgv52r'] 163 164 it('correctly builds a record URI', () => { 165 for (let i = 0; i < inputs.length; i++) { 166 const input = inputs[i] 167 const result = makeRecordUri(...input) 168 expect(result).toEqual(outputs[i]) 169 } 170 }) 171}) 172 173describe('ago', () => { 174 const inputs = [ 175 1671461038, 176 '04 Dec 1995 00:12:00 GMT', 177 new Date(), 178 new Date().setSeconds(new Date().getSeconds() - 10), 179 new Date().setMinutes(new Date().getMinutes() - 10), 180 new Date().setHours(new Date().getHours() - 1), 181 new Date().setDate(new Date().getDate() - 1), 182 new Date().setMonth(new Date().getMonth() - 1), 183 ] 184 const outputs = [ 185 new Date(1671461038).toLocaleDateString(), 186 new Date('04 Dec 1995 00:12:00 GMT').toLocaleDateString(), 187 'now', 188 '10s', 189 '10m', 190 '1h', 191 '1d', 192 '1mo', 193 ] 194 195 it('correctly calculates how much time passed, in a string', () => { 196 for (let i = 0; i < inputs.length; i++) { 197 const result = ago(inputs[i]) 198 expect(result).toEqual(outputs[i]) 199 } 200 }) 201}) 202 203describe('makeValidHandle', () => { 204 const inputs = [ 205 'test-handle-123', 206 'test!"#$%&/()=?_', 207 'this-handle-should-be-too-big', 208 ] 209 const outputs = ['test-handle-123', 'test', 'this-handle-should-b'] 210 211 it('correctly parses and corrects handles', () => { 212 for (let i = 0; i < inputs.length; i++) { 213 const result = makeValidHandle(inputs[i]) 214 expect(result).toEqual(outputs[i]) 215 } 216 }) 217}) 218 219describe('createFullHandle', () => { 220 const inputs: [string, string][] = [ 221 ['test-handle-123', 'test'], 222 ['.test.handle', 'test.test.'], 223 ['test.handle.', '.test.test'], 224 ] 225 const outputs = [ 226 'test-handle-123.test', 227 '.test.handle.test.test.', 228 'test.handle.test.test', 229 ] 230 231 it('correctly parses and corrects handles', () => { 232 for (let i = 0; i < inputs.length; i++) { 233 const input = inputs[i] 234 const result = createFullHandle(...input) 235 expect(result).toEqual(outputs[i]) 236 } 237 }) 238}) 239 240describe('enforceLen', () => { 241 const inputs: [string, number][] = [ 242 ['Hello World!', 5], 243 ['Hello World!', 20], 244 ['', 5], 245 ] 246 const outputs = ['Hello', 'Hello World!', ''] 247 248 it('correctly enforces defined length on a given string', () => { 249 for (let i = 0; i < inputs.length; i++) { 250 const input = inputs[i] 251 const result = enforceLen(...input) 252 expect(result).toEqual(outputs[i]) 253 } 254 }) 255}) 256 257describe('cleanError', () => { 258 const inputs = [ 259 'TypeError: Network request failed', 260 'Error: Aborted', 261 'Error: TypeError "x" is not a function', 262 'Error: SyntaxError unexpected token "export"', 263 'Some other error', 264 ] 265 const outputs = [ 266 'Unable to connect. Please check your internet connection and try again.', 267 'Unable to connect. Please check your internet connection and try again.', 268 'TypeError "x" is not a function', 269 'SyntaxError unexpected token "export"', 270 'Some other error', 271 ] 272 273 it('removes extra content from error message', () => { 274 for (let i = 0; i < inputs.length; i++) { 275 const result = cleanError(inputs[i]) 276 expect(result).toEqual(outputs[i]) 277 } 278 }) 279}) 280 281describe('toNiceDomain', () => { 282 const inputs = [ 283 'https://example.com/index.html', 284 'https://bsky.app', 285 'https://bsky.social', 286 '#123123123', 287 ] 288 const outputs = ['example.com', 'bsky.app', 'Bluesky Social', '#123123123'] 289 290 it("displays the url's host in a easily readable manner", () => { 291 for (let i = 0; i < inputs.length; i++) { 292 const result = toNiceDomain(inputs[i]) 293 expect(result).toEqual(outputs[i]) 294 } 295 }) 296}) 297 298describe('toShortUrl', () => { 299 const inputs = [ 300 'https://bsky.app', 301 'https://bsky.app/3jk7x4irgv52r', 302 'https://bsky.app/3jk7x4irgv52r2313y182h9', 303 'https://very-long-domain-name.com/foo', 304 'https://very-long-domain-name.com/foo?bar=baz#andsomemore', 305 ] 306 const outputs = [ 307 'bsky.app', 308 'bsky.app/3jk7x4irgv52r', 309 'bsky.app/3jk7x4irgv52...', 310 'very-long-domain-name.com/foo', 311 'very-long-domain-name.com/foo?bar=baz#...', 312 ] 313 314 it('shortens the url', () => { 315 for (let i = 0; i < inputs.length; i++) { 316 const result = toShortUrl(inputs[i]) 317 expect(result).toEqual(outputs[i]) 318 } 319 }) 320}) 321 322describe('toShareUrl', () => { 323 const inputs = ['https://bsky.app', '/3jk7x4irgv52r', 'item/test/123'] 324 const outputs = [ 325 'https://bsky.app', 326 'https://bsky.app/3jk7x4irgv52r', 327 'https://bsky.app/item/test/123', 328 ] 329 330 it('appends https, when not present', () => { 331 for (let i = 0; i < inputs.length; i++) { 332 const result = toShareUrl(inputs[i]) 333 expect(result).toEqual(outputs[i]) 334 } 335 }) 336}) 337 338describe('shortenLinks', () => { 339 const inputs = [ 340 'start https://middle.com/foo/bar?baz=bux#hash end', 341 'https://start.com/foo/bar?baz=bux#hash middle end', 342 'start middle https://end.com/foo/bar?baz=bux#hash', 343 'https://newline1.com/very/long/url/here\nhttps://newline2.com/very/long/url/here', 344 'Classic article https://socket3.wordpress.com/2018/02/03/designing-windows-95s-user-interface/', 345 ] 346 const outputs = [ 347 [ 348 'start middle.com/foo/bar?baz=... end', 349 ['https://middle.com/foo/bar?baz=bux#hash'], 350 ], 351 [ 352 'start.com/foo/bar?baz=... middle end', 353 ['https://start.com/foo/bar?baz=bux#hash'], 354 ], 355 [ 356 'start middle end.com/foo/bar?baz=...', 357 ['https://end.com/foo/bar?baz=bux#hash'], 358 ], 359 [ 360 'newline1.com/very/long/ur...\nnewline2.com/very/long/ur...', 361 [ 362 'https://newline1.com/very/long/url/here', 363 'https://newline2.com/very/long/url/here', 364 ], 365 ], 366 [ 367 'Classic article socket3.wordpress.com/2018/02/03/d...', 368 [ 369 'https://socket3.wordpress.com/2018/02/03/designing-windows-95s-user-interface/', 370 ], 371 ], 372 ] 373 374 it('correctly shortens rich text while preserving facet URIs', () => { 375 for (let i = 0; i < inputs.length; i++) { 376 const input = inputs[i] 377 const inputRT = new RichText({text: input}) 378 inputRT.detectFacetsWithoutResolution() 379 const outputRT = shortenLinks(inputRT) 380 expect(outputRT.text).toEqual(outputs[i][0]) 381 expect(outputRT.facets?.length).toEqual(outputs[i][1].length) 382 for (let j = 0; j < outputs[i][1].length; j++) { 383 expect(outputRT.facets![j].features[0].uri).toEqual(outputs[i][1][j]) 384 } 385 } 386 }) 387}) 388 389describe('parseEmbedPlayerFromUrl', () => { 390 const inputs = [ 391 'https://youtu.be/videoId', 392 'https://www.youtube.com/watch?v=videoId', 393 'https://www.youtube.com/watch?v=videoId&feature=share', 394 'https://youtube.com/watch?v=videoId', 395 'https://youtube.com/watch?v=videoId&feature=share', 396 'https://youtube.com/shorts/videoId', 397 'https://m.youtube.com/watch?v=videoId', 398 399 'https://youtube.com/shorts/', 400 'https://youtube.com/', 401 'https://youtube.com/random', 402 403 'https://twitch.tv/channelName', 404 'https://www.twitch.tv/channelName', 405 'https://m.twitch.tv/channelName', 406 407 'https://twitch.tv/channelName/clip/clipId', 408 'https://twitch.tv/videos/videoId', 409 410 'https://open.spotify.com/playlist/playlistId', 411 'https://open.spotify.com/playlist/playlistId?param=value', 412 'https://open.spotify.com/locale/playlist/playlistId', 413 414 'https://open.spotify.com/track/songId', 415 'https://open.spotify.com/track/songId?param=value', 416 'https://open.spotify.com/locale/track/songId', 417 418 'https://open.spotify.com/album/albumId', 419 'https://open.spotify.com/album/albumId?param=value', 420 'https://open.spotify.com/locale/album/albumId', 421 422 'https://soundcloud.com/user/track', 423 'https://soundcloud.com/user/sets/set', 424 'https://soundcloud.com/user/', 425 426 'https://music.apple.com/us/playlist/playlistName/playlistId', 427 'https://music.apple.com/us/album/albumName/albumId', 428 'https://music.apple.com/us/album/albumName/albumId?i=songId', 429 430 'https://vimeo.com/videoId', 431 'https://vimeo.com/videoId?autoplay=0', 432 433 'https://giphy.com/gifs/some-random-gif-name-gifId', 434 'https://giphy.com/gif/some-random-gif-name-gifId', 435 'https://giphy.com/gifs/', 436 437 'https://media.giphy.com/media/gifId/giphy.webp', 438 'https://media0.giphy.com/media/gifId/giphy.webp', 439 'https://media1.giphy.com/media/gifId/giphy.gif', 440 'https://media2.giphy.com/media/gifId/giphy.webp', 441 'https://media3.giphy.com/media/gifId/giphy.mp4', 442 'https://media4.giphy.com/media/gifId/giphy.webp', 443 'https://media5.giphy.com/media/gifId/giphy.mp4', 444 'https://media0.giphy.com/media/gifId/giphy.mp3', 445 'https://media1.google.com/media/gifId/giphy.webp', 446 447 'https://media.giphy.com/media/trackingId/gifId/giphy.webp', 448 449 'https://i.giphy.com/media/gifId/giphy.webp', 450 'https://i.giphy.com/media/gifId/giphy.webp', 451 'https://i.giphy.com/gifId.gif', 452 'https://i.giphy.com/gifId.gif', 453 454 'https://tenor.com/view/gifId', 455 'https://tenor.com/notView/gifId', 456 'https://tenor.com/view', 457 'https://tenor.com/view/gifId.gif', 458 'https://tenor.com/intl/view/gifId.gif', 459 ] 460 461 const outputs = [ 462 { 463 type: 'youtube_video', 464 source: 'youtube', 465 playerUri: 466 'https://www.youtube.com/embed/videoId?autoplay=1&playsinline=1', 467 }, 468 { 469 type: 'youtube_video', 470 source: 'youtube', 471 playerUri: 472 'https://www.youtube.com/embed/videoId?autoplay=1&playsinline=1', 473 }, 474 { 475 type: 'youtube_video', 476 source: 'youtube', 477 playerUri: 478 'https://www.youtube.com/embed/videoId?autoplay=1&playsinline=1', 479 }, 480 { 481 type: 'youtube_video', 482 source: 'youtube', 483 playerUri: 484 'https://www.youtube.com/embed/videoId?autoplay=1&playsinline=1', 485 }, 486 { 487 type: 'youtube_video', 488 source: 'youtube', 489 playerUri: 490 'https://www.youtube.com/embed/videoId?autoplay=1&playsinline=1', 491 }, 492 { 493 type: 'youtube_short', 494 source: 'youtubeShorts', 495 hideDetails: true, 496 playerUri: 497 'https://www.youtube.com/embed/videoId?autoplay=1&playsinline=1', 498 }, 499 { 500 type: 'youtube_video', 501 source: 'youtube', 502 playerUri: 503 'https://www.youtube.com/embed/videoId?autoplay=1&playsinline=1', 504 }, 505 506 undefined, 507 undefined, 508 undefined, 509 510 { 511 type: 'twitch_video', 512 source: 'twitch', 513 playerUri: `https://player.twitch.tv/?volume=0.5&!muted&autoplay&channel=channelName&parent=localhost`, 514 }, 515 { 516 type: 'twitch_video', 517 source: 'twitch', 518 playerUri: `https://player.twitch.tv/?volume=0.5&!muted&autoplay&channel=channelName&parent=localhost`, 519 }, 520 { 521 type: 'twitch_video', 522 source: 'twitch', 523 playerUri: `https://player.twitch.tv/?volume=0.5&!muted&autoplay&channel=channelName&parent=localhost`, 524 }, 525 { 526 type: 'twitch_video', 527 source: 'twitch', 528 playerUri: `https://clips.twitch.tv/embed?volume=0.5&autoplay=true&clip=clipId&parent=localhost`, 529 }, 530 { 531 type: 'twitch_video', 532 source: 'twitch', 533 playerUri: `https://player.twitch.tv/?volume=0.5&!muted&autoplay&video=videoId&parent=localhost`, 534 }, 535 536 { 537 type: 'spotify_playlist', 538 source: 'spotify', 539 playerUri: `https://open.spotify.com/embed/playlist/playlistId`, 540 }, 541 { 542 type: 'spotify_playlist', 543 source: 'spotify', 544 playerUri: `https://open.spotify.com/embed/playlist/playlistId`, 545 }, 546 { 547 type: 'spotify_playlist', 548 source: 'spotify', 549 playerUri: `https://open.spotify.com/embed/playlist/playlistId`, 550 }, 551 552 { 553 type: 'spotify_song', 554 source: 'spotify', 555 playerUri: `https://open.spotify.com/embed/track/songId`, 556 }, 557 { 558 type: 'spotify_song', 559 source: 'spotify', 560 playerUri: `https://open.spotify.com/embed/track/songId`, 561 }, 562 { 563 type: 'spotify_song', 564 source: 'spotify', 565 playerUri: `https://open.spotify.com/embed/track/songId`, 566 }, 567 568 { 569 type: 'spotify_album', 570 source: 'spotify', 571 playerUri: `https://open.spotify.com/embed/album/albumId`, 572 }, 573 { 574 type: 'spotify_album', 575 source: 'spotify', 576 playerUri: `https://open.spotify.com/embed/album/albumId`, 577 }, 578 { 579 type: 'spotify_album', 580 source: 'spotify', 581 playerUri: `https://open.spotify.com/embed/album/albumId`, 582 }, 583 584 { 585 type: 'soundcloud_track', 586 source: 'soundcloud', 587 playerUri: `https://w.soundcloud.com/player/?url=https://soundcloud.com/user/track&auto_play=true&visual=false&hide_related=true`, 588 }, 589 { 590 type: 'soundcloud_set', 591 source: 'soundcloud', 592 playerUri: `https://w.soundcloud.com/player/?url=https://soundcloud.com/user/sets/set&auto_play=true&visual=false&hide_related=true`, 593 }, 594 undefined, 595 596 { 597 type: 'apple_music_playlist', 598 source: 'appleMusic', 599 playerUri: 600 'https://embed.music.apple.com/us/playlist/playlistName/playlistId', 601 }, 602 { 603 type: 'apple_music_album', 604 source: 'appleMusic', 605 playerUri: 'https://embed.music.apple.com/us/album/albumName/albumId', 606 }, 607 { 608 type: 'apple_music_song', 609 source: 'appleMusic', 610 playerUri: 611 'https://embed.music.apple.com/us/album/albumName/albumId?i=songId', 612 }, 613 614 { 615 type: 'vimeo_video', 616 source: 'vimeo', 617 playerUri: 'https://player.vimeo.com/video/videoId?autoplay=1', 618 }, 619 { 620 type: 'vimeo_video', 621 source: 'vimeo', 622 playerUri: 'https://player.vimeo.com/video/videoId?autoplay=1', 623 }, 624 625 { 626 type: 'giphy_gif', 627 source: 'giphy', 628 isGif: true, 629 hideDetails: true, 630 metaUri: 'https://giphy.com/gifs/gifId', 631 playerUri: 'https://i.giphy.com/media/gifId/giphy.webp', 632 }, 633 undefined, 634 undefined, 635 636 { 637 type: 'giphy_gif', 638 source: 'giphy', 639 isGif: true, 640 hideDetails: true, 641 metaUri: 'https://giphy.com/gifs/gifId', 642 playerUri: 'https://i.giphy.com/media/gifId/giphy.webp', 643 }, 644 { 645 type: 'giphy_gif', 646 source: 'giphy', 647 isGif: true, 648 hideDetails: true, 649 metaUri: 'https://giphy.com/gifs/gifId', 650 playerUri: 'https://i.giphy.com/media/gifId/giphy.webp', 651 }, 652 { 653 type: 'giphy_gif', 654 source: 'giphy', 655 isGif: true, 656 hideDetails: true, 657 metaUri: 'https://giphy.com/gifs/gifId', 658 playerUri: 'https://i.giphy.com/media/gifId/giphy.webp', 659 }, 660 { 661 type: 'giphy_gif', 662 source: 'giphy', 663 isGif: true, 664 hideDetails: true, 665 metaUri: 'https://giphy.com/gifs/gifId', 666 playerUri: 'https://i.giphy.com/media/gifId/giphy.webp', 667 }, 668 { 669 type: 'giphy_gif', 670 source: 'giphy', 671 isGif: true, 672 hideDetails: true, 673 metaUri: 'https://giphy.com/gifs/gifId', 674 playerUri: 'https://i.giphy.com/media/gifId/giphy.webp', 675 }, 676 { 677 type: 'giphy_gif', 678 source: 'giphy', 679 isGif: true, 680 hideDetails: true, 681 metaUri: 'https://giphy.com/gifs/gifId', 682 playerUri: 'https://i.giphy.com/media/gifId/giphy.webp', 683 }, 684 undefined, 685 undefined, 686 undefined, 687 688 { 689 type: 'giphy_gif', 690 source: 'giphy', 691 isGif: true, 692 hideDetails: true, 693 metaUri: 'https://giphy.com/gifs/gifId', 694 playerUri: 'https://i.giphy.com/media/gifId/giphy.webp', 695 }, 696 697 { 698 type: 'giphy_gif', 699 source: 'giphy', 700 isGif: true, 701 hideDetails: true, 702 metaUri: 'https://giphy.com/gifs/gifId', 703 playerUri: 'https://i.giphy.com/media/gifId/giphy.webp', 704 }, 705 { 706 type: 'giphy_gif', 707 source: 'giphy', 708 isGif: true, 709 hideDetails: true, 710 metaUri: 'https://giphy.com/gifs/gifId', 711 playerUri: 'https://i.giphy.com/media/gifId/giphy.webp', 712 }, 713 { 714 type: 'giphy_gif', 715 source: 'giphy', 716 isGif: true, 717 hideDetails: true, 718 metaUri: 'https://giphy.com/gifs/gifId', 719 playerUri: 'https://i.giphy.com/media/gifId/giphy.webp', 720 }, 721 { 722 type: 'giphy_gif', 723 source: 'giphy', 724 isGif: true, 725 hideDetails: true, 726 metaUri: 'https://giphy.com/gifs/gifId', 727 playerUri: 'https://i.giphy.com/media/gifId/giphy.webp', 728 }, 729 730 { 731 type: 'tenor_gif', 732 source: 'tenor', 733 isGif: true, 734 hideDetails: true, 735 playerUri: 'https://tenor.com/view/gifId.gif', 736 }, 737 undefined, 738 undefined, 739 { 740 type: 'tenor_gif', 741 source: 'tenor', 742 isGif: true, 743 hideDetails: true, 744 playerUri: 'https://tenor.com/view/gifId.gif', 745 }, 746 { 747 type: 'tenor_gif', 748 source: 'tenor', 749 isGif: true, 750 hideDetails: true, 751 playerUri: 'https://tenor.com/intl/view/gifId.gif', 752 }, 753 ] 754 755 it('correctly grabs the correct id from uri', () => { 756 for (let i = 0; i < inputs.length; i++) { 757 const input = inputs[i] 758 const output = outputs[i] 759 760 const res = parseEmbedPlayerFromUrl(input) 761 762 console.log(input) 763 764 expect(res).toEqual(output) 765 } 766 }) 767})