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