mirror of
https://github.com/Permissionless-Software-Foundation/psf-memo.git
synced 2026-09-21 16:52:01 -07:00
Review youtube-embed: harden parser edge cases, document equivalents
Add unit tests for invalid video id and non-/watch youtube.com URL to kill mutation survivors; document the match[1]/match[0] equivalent and the soft-Gherkin example-value equivalents. By architect.
This commit is contained in:
@@ -1,3 +1,7 @@
|
||||
# acceptance-mutation-manifest-begin
|
||||
# {"version":1,"tested_at":"2026-09-04T16:25:46.345890783Z","feature_name":"YouTube Embed","feature_path":"/home/trout/work/psf-memo/.worktrees/architect/psf-memo-client/specs/youtube-embed.feature","background_hash":"0d66780cb1b8e277f0ada40a8ffe336dec7a8eaf658f19d2ea344815fb9bf26c","implementation_hash":"unknown","scenarios":[]}
|
||||
# acceptance-mutation-manifest-end
|
||||
|
||||
# Scenarios: YouTube Embed - 1, YouTube Embed - 2, YouTube Embed - 3
|
||||
#
|
||||
# When a post's text contains a YouTube link, the client renders an embedded
|
||||
|
||||
@@ -111,3 +111,7 @@ module.exports = {
|
||||
extractYouTubeVideoId,
|
||||
parsePostText
|
||||
}
|
||||
|
||||
// mutate4javascript-manifest-begin
|
||||
// {"version":1,"tested_at":"2026-09-04T16:24:43.962Z","module_hash":"102305b0a6a2998c7271bbfdecc272fbe426ecc2dac61f89f74cde410372c52f","functions":[{"id":"func/validVideoId","name":"validVideoId","line":14,"end_line":16,"hash":"cf16fbd8a480a0cffa21699ddb96d1c7ecf746ad06503b97022f7e4a7376ddff"},{"id":"func/parseCandidate","name":"parseCandidate","line":20,"end_line":28,"hash":"7b2588b1e113b390c14d08a99befb0a2bd844ed4b0057a577d6dc97c8f3c4d20"},{"id":"func/videoIdFromWatchUrl","name":"videoIdFromWatchUrl","line":31,"end_line":34,"hash":"dde2829ca98d70aae061202de77df0adb7fb774a5aca1ba080e062b157391672"},{"id":"func/videoIdFromShortUrl","name":"videoIdFromShortUrl","line":37,"end_line":40,"hash":"a0a6934232c55cfd7d80c825fd65f337c9fd35a5cbb09ab12b834c34b520624e"},{"id":"func/extractYouTubeVideoId","name":"extractYouTubeVideoId","line":46,"end_line":61,"hash":"9559c0264f22c094687249f330bb514a7514955c115384e292ddb9e16df8afe7"},{"id":"func/pushText","name":"pushText","line":66,"end_line":68,"hash":"abda2060349c814451b88fe350ca235069afdc769eaa3ffa90e9d214673c71b9"},{"id":"func/parsePostText","name":"parsePostText","line":75,"end_line":107,"hash":"ab68477ea4145245c47def1a3ac2a0cfd4ed62725000bd1d669b7bde160435c5"}]}
|
||||
// mutate4javascript-manifest-end
|
||||
|
||||
@@ -35,6 +35,14 @@ test('extractYouTubeVideoId returns null when the watch URL has no v value', ()
|
||||
assert.equal(extractYouTubeVideoId('https://www.youtube.com/watch?v='), null)
|
||||
})
|
||||
|
||||
test('extractYouTubeVideoId returns null for a watch URL with an invalid video id', () => {
|
||||
assert.equal(extractYouTubeVideoId('https://www.youtube.com/watch?v=abc!def'), null)
|
||||
})
|
||||
|
||||
test('extractYouTubeVideoId returns null for a youtube.com URL that is not /watch', () => {
|
||||
assert.equal(extractYouTubeVideoId('https://www.youtube.com/not-watch?v=abc'), null)
|
||||
})
|
||||
|
||||
test('extractYouTubeVideoId returns null when the short URL has no path id', () => {
|
||||
assert.equal(extractYouTubeVideoId('https://youtu.be/'), null)
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user