#150 - Sort notes in dd-Mmm-yyyy format

- additional unit tests
- fixes detected by unit tests

Next step: manual local testing of real scenarios
This commit is contained in:
SebastianMC 2024-07-08 23:49:24 +02:00
parent a7b807d5f5
commit 92a33215cc
3 changed files with 12 additions and 4 deletions

View File

@ -8,7 +8,7 @@ export const NumberRegexStr: string = ' *(\\d+)'; // Plain number
export const CompoundNumberDotRegexStr: string = ' *(\\d+(?:\\.\\d+)*)'; // Compound number with dot as separator
export const CompoundNumberDashRegexStr: string = ' *(\\d+(?:-\\d+)*)'; // Compound number with dash as separator
export const Date_dd_Mmm_yyyy_RegexStr: string = ' *[0-3]*[0-9]-{Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec}-\\d{4}'; // Date like 01-Jan-2020
export const Date_dd_Mmm_yyyy_RegexStr: string = ' *[0-3]*[0-9]-(?:Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)-\\d{4}'; // Date like 01-Jan-2020
export const DOT_SEPARATOR = '.'
export const DASH_SEPARATOR = '-'

View File

@ -498,7 +498,7 @@ const sortingSymbolToRegexpStr: { [key: string]: RegExpSpecStr } = {
[Date_dd_Mmm_yyyy_RegexSymbol]: { // Intentionally retain character case
regexpStr: Date_dd_Mmm_yyyy_RegexStr,
normalizerFn: Date_dd_Mmm_yyyy_NormalizerFn,
advancedRegexType: AdvancedRegexType.RomanNumber
advancedRegexType: AdvancedRegexType.Date_dd_Mmm_yyyy
}
}

View File

@ -4,7 +4,7 @@ import {
CompoundDotNumberNormalizerFn,
ConsumedFolderMatchingRegexp,
consumeFolderByRegexpExpression,
convertPlainStringToRegex,
convertPlainStringToRegex, Date_dd_Mmm_yyyy_NormalizerFn,
detectSortingSymbols,
escapeRegexUnsafeCharacters,
extractSortingSymbol,
@ -404,11 +404,17 @@ const expectedSortSpecsExampleSortingSymbols: { [key: string]: CustomSortSpec }
regex: /^(\p{Letter}+)\. is for any modern language word$/iu,
normalizerFn: IdentityNormalizerFn
}
}, {
type: CustomSortGroupType.ExactName,
regexPrefix: {
regex: /^ *[0-3]*[0-9]-(?:Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)-\d{4} for the specific date format of 12\-Apr\-2024$/i,
normalizerFn: Date_dd_Mmm_yyyy_NormalizerFn
}
}, {
type: CustomSortGroupType.Outsiders
}],
targetFoldersPaths: ['mock-folder'],
outsidersGroupIdx: 7
outsidersGroupIdx: 8
}
}
@ -420,6 +426,7 @@ Plain syntax\\R+ ... works?
And this kind of... \\D+plain syntax???
Here goes ASCII word \\a+
\\A+. is for any modern language word
\\[dd-Mmm-yyyy] for the specific date format of 12-Apr-2024
`
describe('SortingSpecProcessor', () => {
@ -3141,6 +3148,7 @@ describe('hasMoreThanOneSortingSymbol', () => {
['\\-r+', false], ['--\\-r+--\\-D+++', true],
['\\d+abcd\\d+efgh', true],
['\\R+abcd\\.R+efgh', true],
['\\R+abcd\\[dd-Mmm-yyyy]', true],
['\\d+\\.D+\\-d+\\R+\\.r+\\-R+ \\d+', true]
])('should correctly detect in >%s< (%s) sorting regex symbols', (s: string, b: boolean) => {
const result = hasMoreThanOneSortingSymbol(s)