From aca86e022879c60dcf5246acf21920ae04b83b94 Mon Sep 17 00:00:00 2001 From: Isaac Abadi Date: Sat, 18 Jun 2022 20:09:11 -0400 Subject: [PATCH] Added test for ID3 tagging --- backend/test/tests.js | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/backend/test/tests.js b/backend/test/tests.js index 448db7b..c87045a 100644 --- a/backend/test/tests.js +++ b/backend/test/tests.js @@ -39,6 +39,7 @@ const utils = require('../utils'); const subscriptions_api = require('../subscriptions'); const fs = require('fs-extra'); const { uuid } = require('uuidv4'); +const NodeID3 = require('node-id3'); db_api.initialize(db, users_db); @@ -399,6 +400,19 @@ describe('Downloader', function() { }); + it('Tag file', async function() { + const audio_path = './test/sample.mp3'; + const sample_json = fs.readJSONSync('./test/sample.info.json'); + const tags = { + title: sample_json['title'], + artist: sample_json['artist'] ? sample_json['artist'] : sample_json['uploader'], + TRCK: '27' + } + NodeID3.write(tags, audio_path); + const written_tags = NodeID3.read(audio_path); + assert(written_tags['raw']['TRCK'] === '27'); + }); + it('Queue file', async function() { this.timeout(300000); const returned_download = await downloader_api.createDownload(url, 'video', options);