From 158197fb226f39c10fa7a21eb443128b4c6a1f9f Mon Sep 17 00:00:00 2001 From: Aleksandr Statciuk Date: Fri, 21 Jan 2022 20:06:29 +0300 Subject: [PATCH] Update save-results.js --- scripts/commands/save-results.js | 2 +- tests/commands/save-results.test.js | 16 ++++++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/scripts/commands/save-results.js b/scripts/commands/save-results.js index 667692db..49596f88 100644 --- a/scripts/commands/save-results.js +++ b/scripts/commands/save-results.js @@ -34,7 +34,7 @@ async function main() { if (result.channel.logo) { await db.channels.update( { _id: result.channel._id }, - { $set: { logo: result.channel.logo } } + { $set: { logo: result.channel.logo, programCount: result.programs.length } } ) } diff --git a/tests/commands/save-results.test.js b/tests/commands/save-results.test.js index acb6c68d..38cbb363 100644 --- a/tests/commands/save-results.test.js +++ b/tests/commands/save-results.test.js @@ -42,6 +42,22 @@ it('can save results', () => { const channels = content('tests/__data__/output/database/channels.db') + expect(Object.keys(channels[0]).sort()).toEqual([ + '_id', + 'channelsPath', + 'cluster_id', + 'configPath', + 'country', + 'groups', + 'lang', + 'logo', + 'name', + 'programCount', + 'site', + 'site_id', + 'xmltv_id' + ]) + expect(channels[1]).toMatchObject({ _id: '0Wefq0oMR3feCcuY', logo: 'https://example.com/logo.png'