#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:
parent
a7b807d5f5
commit
92a33215cc
|
@ -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 CompoundNumberDotRegexStr: string = ' *(\\d+(?:\\.\\d+)*)'; // Compound number with dot as separator
|
||||||
export const CompoundNumberDashRegexStr: string = ' *(\\d+(?:-\\d+)*)'; // Compound number with dash 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 DOT_SEPARATOR = '.'
|
||||||
export const DASH_SEPARATOR = '-'
|
export const DASH_SEPARATOR = '-'
|
||||||
|
|
|
@ -498,7 +498,7 @@ const sortingSymbolToRegexpStr: { [key: string]: RegExpSpecStr } = {
|
||||||
[Date_dd_Mmm_yyyy_RegexSymbol]: { // Intentionally retain character case
|
[Date_dd_Mmm_yyyy_RegexSymbol]: { // Intentionally retain character case
|
||||||
regexpStr: Date_dd_Mmm_yyyy_RegexStr,
|
regexpStr: Date_dd_Mmm_yyyy_RegexStr,
|
||||||
normalizerFn: Date_dd_Mmm_yyyy_NormalizerFn,
|
normalizerFn: Date_dd_Mmm_yyyy_NormalizerFn,
|
||||||
advancedRegexType: AdvancedRegexType.RomanNumber
|
advancedRegexType: AdvancedRegexType.Date_dd_Mmm_yyyy
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,7 @@ import {
|
||||||
CompoundDotNumberNormalizerFn,
|
CompoundDotNumberNormalizerFn,
|
||||||
ConsumedFolderMatchingRegexp,
|
ConsumedFolderMatchingRegexp,
|
||||||
consumeFolderByRegexpExpression,
|
consumeFolderByRegexpExpression,
|
||||||
convertPlainStringToRegex,
|
convertPlainStringToRegex, Date_dd_Mmm_yyyy_NormalizerFn,
|
||||||
detectSortingSymbols,
|
detectSortingSymbols,
|
||||||
escapeRegexUnsafeCharacters,
|
escapeRegexUnsafeCharacters,
|
||||||
extractSortingSymbol,
|
extractSortingSymbol,
|
||||||
|
@ -404,11 +404,17 @@ const expectedSortSpecsExampleSortingSymbols: { [key: string]: CustomSortSpec }
|
||||||
regex: /^(\p{Letter}+)\. is for any modern language word$/iu,
|
regex: /^(\p{Letter}+)\. is for any modern language word$/iu,
|
||||||
normalizerFn: IdentityNormalizerFn
|
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
|
type: CustomSortGroupType.Outsiders
|
||||||
}],
|
}],
|
||||||
targetFoldersPaths: ['mock-folder'],
|
targetFoldersPaths: ['mock-folder'],
|
||||||
outsidersGroupIdx: 7
|
outsidersGroupIdx: 8
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -420,6 +426,7 @@ Plain syntax\\R+ ... works?
|
||||||
And this kind of... \\D+plain syntax???
|
And this kind of... \\D+plain syntax???
|
||||||
Here goes ASCII word \\a+
|
Here goes ASCII word \\a+
|
||||||
\\A+. is for any modern language word
|
\\A+. is for any modern language word
|
||||||
|
\\[dd-Mmm-yyyy] for the specific date format of 12-Apr-2024
|
||||||
`
|
`
|
||||||
|
|
||||||
describe('SortingSpecProcessor', () => {
|
describe('SortingSpecProcessor', () => {
|
||||||
|
@ -3141,6 +3148,7 @@ describe('hasMoreThanOneSortingSymbol', () => {
|
||||||
['\\-r+', false], ['--\\-r+--\\-D+++', true],
|
['\\-r+', false], ['--\\-r+--\\-D+++', true],
|
||||||
['\\d+abcd\\d+efgh', true],
|
['\\d+abcd\\d+efgh', true],
|
||||||
['\\R+abcd\\.R+efgh', true],
|
['\\R+abcd\\.R+efgh', true],
|
||||||
|
['\\R+abcd\\[dd-Mmm-yyyy]', true],
|
||||||
['\\d+\\.D+\\-d+\\R+\\.r+\\-R+ \\d+', true]
|
['\\d+\\.D+\\-d+\\R+\\.r+\\-R+ \\d+', true]
|
||||||
])('should correctly detect in >%s< (%s) sorting regex symbols', (s: string, b: boolean) => {
|
])('should correctly detect in >%s< (%s) sorting regex symbols', (s: string, b: boolean) => {
|
||||||
const result = hasMoreThanOneSortingSymbol(s)
|
const result = hasMoreThanOneSortingSymbol(s)
|
||||||
|
|
Loading…
Reference in New Issue