more tests
This commit is contained in:
parent
217d9de761
commit
d9cbbb9076
|
@ -0,0 +1,12 @@
|
||||||
|
const presets = [
|
||||||
|
[
|
||||||
|
"@babel/preset-env",
|
||||||
|
{
|
||||||
|
targets: {
|
||||||
|
node: 'current'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
];
|
||||||
|
|
||||||
|
module.exports = { presets };
|
|
@ -1,7 +0,0 @@
|
||||||
const presets = [
|
|
||||||
[
|
|
||||||
"@babel/preset-env",
|
|
||||||
]
|
|
||||||
];
|
|
||||||
|
|
||||||
module.exports = { presets };
|
|
|
@ -44,24 +44,20 @@ describe('detection in file name', () => {
|
||||||
|
|
||||||
describe('modification in file name', () => {
|
describe('modification in file name', () => {
|
||||||
|
|
||||||
let fileNameOriginal = 'mon texte -- famille vacances plage.jpg'
|
|
||||||
let properties = finder.destructurateFileName(fileNameOriginal)
|
|
||||||
|
|
||||||
test('should append to file name in the right place', () => {
|
test('should append to file name in the right place', () => {
|
||||||
|
let fileNameOriginal = 'mon texte -- famille vacances plage.jpg'
|
||||||
|
let properties = finder.destructurateFileName(fileNameOriginal)
|
||||||
let modifiedProperties = finder.appendFileName(properties, 'ajouté à la fin du texte libre')
|
let modifiedProperties = finder.appendFileName(properties, 'ajouté à la fin du texte libre')
|
||||||
expect(
|
expect(
|
||||||
modifiedProperties.freeText
|
modifiedProperties.freeText
|
||||||
)
|
)
|
||||||
.toBe('mon texte ajouté à la fin du texte libre')
|
.toBe('mon texte ajouté à la fin du texte libre')
|
||||||
})
|
})
|
||||||
test('should prepend to file name in the right place', () => {
|
|
||||||
let modifiedProperties = finder.prependFileName(properties, 'ajouté au début du texte libre ')
|
|
||||||
expect(
|
|
||||||
modifiedProperties.freeText
|
|
||||||
)
|
|
||||||
.toBe('ajouté au début du texte libre mon texte')
|
|
||||||
})
|
|
||||||
test('should replace text in file name', () => {
|
test('should replace text in file name', () => {
|
||||||
|
let fileNameOriginal = 'mon texte -- famille vacances plage.jpg'
|
||||||
let searchString = 'vacances', replaceString = 'machin'
|
let searchString = 'vacances', replaceString = 'machin'
|
||||||
let replacedString = finder.searchAndReplaceInFileName(searchString, replaceString, fileNameOriginal)
|
let replacedString = finder.searchAndReplaceInFileName(searchString, replaceString, fileNameOriginal)
|
||||||
expect(
|
expect(
|
||||||
|
@ -70,6 +66,25 @@ describe('modification in file name', () => {
|
||||||
.toBe('mon texte -- famille machin plage.jpg')
|
.toBe('mon texte -- famille machin plage.jpg')
|
||||||
})
|
})
|
||||||
|
|
||||||
|
test('should prepend to file name in the right place', () => {
|
||||||
|
let fileNameOriginal = 'mon texte.jpg'
|
||||||
|
let properties = finder.destructurateFileName(fileNameOriginal)
|
||||||
|
let modifiedProperties = finder.prependFileName(properties, 'au début')
|
||||||
|
expect(
|
||||||
|
modifiedProperties.freeText
|
||||||
|
)
|
||||||
|
.toBe('au début mon texte')
|
||||||
|
})
|
||||||
|
|
||||||
|
test('should clean spaces', () => {
|
||||||
|
let fileNameOriginal = ' mon texte - - -- bidule un truc '
|
||||||
|
|
||||||
|
expect(
|
||||||
|
finder.cleanSpaces(fileNameOriginal)
|
||||||
|
)
|
||||||
|
.toBe('mon texte - - -- bidule un truc')
|
||||||
|
})
|
||||||
|
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('modifications with tags', () => {
|
describe('modifications with tags', () => {
|
||||||
|
@ -84,6 +99,7 @@ describe('modifications with tags', () => {
|
||||||
.toStrictEqual([])
|
.toStrictEqual([])
|
||||||
|
|
||||||
})
|
})
|
||||||
|
|
||||||
test('should list existing tags in file name', () => {
|
test('should list existing tags in file name', () => {
|
||||||
let fileNameOriginal = 'mon nom -- carte bidule.jpg'
|
let fileNameOriginal = 'mon nom -- carte bidule.jpg'
|
||||||
let otherProperties = finder.destructurateFileName(fileNameOriginal)
|
let otherProperties = finder.destructurateFileName(fileNameOriginal)
|
||||||
|
@ -94,8 +110,8 @@ describe('modifications with tags', () => {
|
||||||
.toStrictEqual(['carte', 'bidule'])
|
.toStrictEqual(['carte', 'bidule'])
|
||||||
|
|
||||||
})
|
})
|
||||||
test('should add tag in file name', () => {
|
|
||||||
|
|
||||||
|
test('should add tag in file name', () => {
|
||||||
let newTag = 'illustration'
|
let newTag = 'illustration'
|
||||||
let newName = finder.addTagInFileName(newTag, fileNameOriginal)
|
let newName = finder.addTagInFileName(newTag, fileNameOriginal)
|
||||||
|
|
||||||
|
|
|
@ -114,7 +114,7 @@ export default class finder {
|
||||||
}
|
}
|
||||||
|
|
||||||
static cleanSpaces (inputString) {
|
static cleanSpaces (inputString) {
|
||||||
return inputString.trim().replace(/ *g/, ' ')
|
return inputString.trim().replace(/ *g/, ' ').replace(/ /, ' ')
|
||||||
}
|
}
|
||||||
|
|
||||||
static searchAndReplaceInFileName (searchString, replaceString, fileName) {
|
static searchAndReplaceInFileName (searchString, replaceString, fileName) {
|
||||||
|
@ -269,9 +269,7 @@ export default class finder {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static findTemplateInFileName (fileName) {
|
|
||||||
// test all templates from configuration
|
|
||||||
}
|
|
||||||
|
|
||||||
static appendFileName (fileProperties, newText) {
|
static appendFileName (fileProperties, newText) {
|
||||||
fileProperties.freeText = finder.cleanSpaces(fileProperties.freeText + ' ' + newText)
|
fileProperties.freeText = finder.cleanSpaces(fileProperties.freeText + ' ' + newText)
|
||||||
|
|
|
@ -8,27 +8,35 @@ import fs from 'node-fs'
|
||||||
---------------------------------------------------------------------
|
---------------------------------------------------------------------
|
||||||
**/
|
**/
|
||||||
|
|
||||||
function LogActionRun(){
|
class notReadyFunctions {
|
||||||
|
|
||||||
|
static LogActionRun () {
|
||||||
// get file which contains logs
|
// get file which contains logs
|
||||||
// add an entry
|
// add an entry
|
||||||
// persist log file
|
// persist log file
|
||||||
}
|
}
|
||||||
|
|
||||||
function ListActions(idOfAction){
|
static ListActions (idOfAction) {
|
||||||
// retrieve log of actions from file
|
// retrieve log of actions from file
|
||||||
}
|
}
|
||||||
function RevertAction(idOfAction){
|
|
||||||
|
static RevertAction (idOfAction) {
|
||||||
// select action and run all renames in the other way
|
// select action and run all renames in the other way
|
||||||
}
|
}
|
||||||
function RevertMultipleActionsUntil(idOfAction){
|
|
||||||
|
static RevertMultipleActionsUntil (idOfAction) {
|
||||||
// select action and run all renames in the other way for each point in time
|
// select action and run all renames in the other way for each point in time
|
||||||
}
|
}
|
||||||
|
|
||||||
function TestDownloadedTelegramPictureRename (fileName) {
|
static findTemplateInFileName (fileName) {
|
||||||
|
// test all templates from configuration
|
||||||
|
}
|
||||||
|
|
||||||
|
static TestDownloadedTelegramPictureRename (fileName) {
|
||||||
let fileProperties = destructurateFileName(fileName)
|
let fileProperties = destructurateFileName(fileName)
|
||||||
}
|
}
|
||||||
|
|
||||||
function hasDifferentDateInNameThanExif (fileName) {
|
static hasDifferentDateInNameThanExif (fileName) {
|
||||||
let foundDate = finder.findFormattedDate(fileName)
|
let foundDate = finder.findFormattedDate(fileName)
|
||||||
|
|
||||||
if (foundDate && foundDate != getExifCreationDate(fileName)) {
|
if (foundDate && foundDate != getExifCreationDate(fileName)) {
|
||||||
|
@ -37,12 +45,12 @@ function hasDifferentDateInNameThanExif (fileName) {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
function moveToArchive (targetDirectory, fileFullPath) {
|
static moveToArchive (targetDirectory, fileFullPath) {
|
||||||
// find current directory,
|
// find current directory,
|
||||||
// rename file to move it
|
// rename file to move it
|
||||||
}
|
}
|
||||||
|
|
||||||
function getStatisticsOnArchiveFolder (fileFullPath) {
|
static getStatisticsOnArchiveFolder (fileFullPath) {
|
||||||
|
|
||||||
return {
|
return {
|
||||||
foldersCount: 'TODO',
|
foldersCount: 'TODO',
|
||||||
|
@ -55,15 +63,15 @@ function getStatisticsOnArchiveFolder (fileFullPath) {
|
||||||
* @param fileFullPath
|
* @param fileFullPath
|
||||||
* @returns {[]}
|
* @returns {[]}
|
||||||
*/
|
*/
|
||||||
function getControlledVocabularyFromFiles (fileFullPath) {
|
static getControlledVocabularyFromFiles (fileFullPath) {
|
||||||
|
|
||||||
// find all tags
|
// find all tags
|
||||||
let listOfTags = []
|
let listOfTags = []
|
||||||
|
|
||||||
return listOfTags;
|
return listOfTags
|
||||||
}
|
}
|
||||||
|
|
||||||
function moveToSortingFolder (fileFullPath) {
|
static moveToSortingFolder (fileFullPath) {
|
||||||
return 'TODO'
|
return 'TODO'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -73,13 +81,13 @@ function moveToSortingFolder (fileFullPath) {
|
||||||
* @param originalFileName
|
* @param originalFileName
|
||||||
* @returns {*}
|
* @returns {*}
|
||||||
*/
|
*/
|
||||||
function mixDateNameWithFileName (convertedToName, originalFileName) {
|
static mixDateNameWithFileName (convertedToName, originalFileName) {
|
||||||
// enlever l'ancien timestamp si il existe
|
// enlever l'ancien timestamp si il existe
|
||||||
// ajouter en début de nom le nouveau timestamp avec un espace et conserver le reste du nom
|
// ajouter en début de nom le nouveau timestamp avec un espace et conserver le reste du nom
|
||||||
return originalFileName
|
return originalFileName
|
||||||
}
|
}
|
||||||
|
|
||||||
function TestMixingName () {
|
static TestMixingName () {
|
||||||
|
|
||||||
let fileMixedNewName = mixDateNameWithFileName(convertedToName, originalFileName)
|
let fileMixedNewName = mixDateNameWithFileName(convertedToName, originalFileName)
|
||||||
console.log('new name', fileMixedNewName)
|
console.log('new name', fileMixedNewName)
|
||||||
|
@ -90,25 +98,23 @@ function TestMixingName () {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* obtenir une liste des dossiers uniquement dans le dossier courant
|
* obtenir une liste des dossiers uniquement dans le dossier courant
|
||||||
* @param path
|
* @param path
|
||||||
* @returns {*}
|
* @returns {*}
|
||||||
*/
|
*/
|
||||||
function getDirectories (path) {
|
static getDirectories (path) {
|
||||||
return fs.readdirSync(path).filter(function (file) {
|
return fs.readdirSync(path).filter(function (file) {
|
||||||
return fs.statSync(path + '/' + file).isDirectory()
|
return fs.statSync(path + '/' + file).isDirectory()
|
||||||
})
|
}
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static convertDateToTimeInFileName (inputDate) {
|
||||||
function convertDateToTimeInFileName (inputDate) {
|
|
||||||
return inputDate.replace(' ', 'T')
|
return inputDate.replace(' ', 'T')
|
||||||
}
|
}
|
||||||
|
|
||||||
function testthings(){
|
static testthings () {
|
||||||
// let list = getDirectories(pathFolder)
|
// let list = getDirectories(pathFolder)
|
||||||
// console.log('list', list)
|
// console.log('list', list)
|
||||||
|
|
||||||
|
@ -124,3 +130,6 @@ function testthings(){
|
||||||
console.log('convertedToName', convertedToName)
|
console.log('convertedToName', convertedToName)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
export default notReadyFunctions
|
Loading…
Reference in New Issue