A clean and minimal youtube frontend, without all the ads and whistles
JavaScript
feat: upsert single video
Christian Fei1e00822ef60a
diff --git a/lib/repository.js b/lib/repository.jsindex a3c976b..9bfc042 100644--- a/lib/repository.js+++ b/lib/repository.js@@ -60,7 +60,8 @@ export default class Repository {return this.videos.filter(v => v.channelName === name)}upsertVideos(videos) {- videos.forEach(v => {+ (Array.isArray(videos) ? videos : [videos])+ .forEach(v => {const index = this.videos.findIndex(video => video.id === v.id)if (index !== -1) {this.videos[index] = vdiff --git a/test/repository.test.js b/test/repository.test.jsindex 2ac95dd..9fbd3b3 100644--- a/test/repository.test.js+++ b/test/repository.test.js@@ -40,6 +40,11 @@ test('upserts videos', () => {assert.equal(repo.getVideos().length, 2)})+test('upserts single video', () => {+ repo.upsertVideos(video1)+ assert.equal(repo.getVideos().length, 1)+})+test('gets channel videos', () => {repo.upsertVideos([video1, video2])const videos = repo.getChannelVideos('tester')