From 7c56b3a5174369a6aee8ad5e46661972e222761a Mon Sep 17 00:00:00 2001 From: "greg.pringle" <5757188+Tailslide@users.noreply.github.com> Date: Fri, 17 Feb 2023 00:41:28 -0700 Subject: [PATCH] Add tests, fix errors --- .../Tdarr_Plugin_tsld_filter_modified_date.js | 8 +-- .../Tdarr_Plugin_tsld_filter_modified_date.js | 63 +++++++++++++++++++ 2 files changed, 67 insertions(+), 4 deletions(-) create mode 100644 tests/Community/Tdarr_Plugin_tsld_filter_modified_date.js diff --git a/Community/Tdarr_Plugin_tsld_filter_modified_date.js b/Community/Tdarr_Plugin_tsld_filter_modified_date.js index 6e8d56f..38e5b16 100644 --- a/Community/Tdarr_Plugin_tsld_filter_modified_date.js +++ b/Community/Tdarr_Plugin_tsld_filter_modified_date.js @@ -12,9 +12,9 @@ const details = () => ({ { name: 'minModifiedDaysOld', type: 'number', - defaultValue: '30', + defaultValue: 30, inputUI: { - type: 'number', + type: 'text', }, tooltip: `Enter minimum number of days since modified since now file must be. @@ -43,12 +43,12 @@ const plugin = (file, librarySettings, inputs, otherArguments) => { // response.infoLog += ` Age ${age} Require Min Age: ${reqage}`; if (reqage < age) { - // response.infoLog += " Old enough, lets do this!"; + response.infoLog += "File modified date old enough. Moving to next plugin."; response.processFile = true; } else { - response.infoLog += " Skipping, file modified date not old enough"; + response.infoLog += "Skipping, file modified date not old enough"; response.processFile = false; } diff --git a/tests/Community/Tdarr_Plugin_tsld_filter_modified_date.js b/tests/Community/Tdarr_Plugin_tsld_filter_modified_date.js new file mode 100644 index 0000000..ffc6852 --- /dev/null +++ b/tests/Community/Tdarr_Plugin_tsld_filter_modified_date.js @@ -0,0 +1,63 @@ +/* eslint max-len: 0 */ +const run = require('../helpers/run'); + +const tests = [ + { + input: { + file: require('../sampleData/media/sampleH264_2.json'), + librarySettings: {}, + inputs: { + minModifiedDaysOld: 1 + }, + otherArguments: {}, + }, + output: { + processFile: true, + infoLog: 'File modified date old enough. Moving to next plugin.', + }, + }, + { + input: { + file: require('../sampleData/media/sampleH264_1.json'), + librarySettings: {}, + inputs: { + minModifiedDaysOld: 9999 + }, + otherArguments: {}, + }, + output: { + processFile: false, + infoLog: 'Skipping, file modified date not old enough', + }, + }, + { + input: { + file: require('../sampleData/media/sampleH264_1.json'), + librarySettings: {}, + inputs: { + minModifiedDaysOld: 1 + }, + otherArguments: {}, + }, + output: { + processFile: true, + infoLog: 'File modified date old enough. Moving to next plugin.', + }, + }, + { + input: { + file: require('../sampleData/media/sampleH264_1.json'), + librarySettings: {}, + inputs: { + minModifiedDaysOld: 9999 + }, + otherArguments: {}, + }, + output: { + processFile: false, + infoLog: 'Skipping, file modified date not old enough', + }, + }, +]; + +run(tests); \ No newline at end of file