feat: Generalize and extend notification channel type behaviour

This commit is contained in:
Joachim Van Herwegen
2023-01-27 11:53:30 +01:00
parent 7d029a9465
commit c36f15e2da
32 changed files with 1291 additions and 624 deletions

View File

@@ -1,7 +1,7 @@
import {
sanitizeUrlPart,
splitCommaSeparated,
isValidFileName,
isValidFileName, msToDuration,
} from '../../../src/util/StringUtil';
describe('HeaderUtil', (): void => {
@@ -31,4 +31,21 @@ describe('HeaderUtil', (): void => {
expect(isValidFileName('$%^*')).toBeFalsy();
});
});
describe('#msToDuration', (): void => {
it('converts ms to a duration string.', async(): Promise<void> => {
const ms = ((2 * 24 * 60 * 60) + (10 * 60 * 60) + (5 * 60) + 50.25) * 1000;
expect(msToDuration(ms)).toBe('P2DT10H5M50.25S');
});
it('ignores 0 values.', async(): Promise<void> => {
const ms = ((2 * 24 * 60 * 60) + 50.25) * 1000;
expect(msToDuration(ms)).toBe('P2DT50.25S');
});
it('excludes the T if there is no time segment.', async(): Promise<void> => {
const ms = ((2 * 24 * 60 * 60)) * 1000;
expect(msToDuration(ms)).toBe('P2D');
});
});
});