test: common-utils
This commit is contained in:
parent
a6888c4653
commit
cb17e72f31
|
|
@ -1,5 +1,5 @@
|
|||
.DS_Store
|
||||
.env
|
||||
.env*
|
||||
.eslintcache
|
||||
.idea
|
||||
.log
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
const utils = require('../../lib/utils/common-utils');
|
||||
import { describe, expect, it } from '@jest/globals';
|
||||
import utils from './common-utils';
|
||||
|
||||
describe('common-utils', () => {
|
||||
it('toTitleCase', () => {
|
||||
|
|
@ -8,14 +8,14 @@ const rWhiteSpace = /\s+/;
|
|||
const rAllWhiteSpace = /\s+/g;
|
||||
|
||||
// collapse all whitespaces into a single space (like "white-space: normal;" would do), and trim
|
||||
const collapseWhitespace = (str: string) => {
|
||||
const collapseWhitespace = (str?: string | null) => {
|
||||
if (str && rWhiteSpace.test(str)) {
|
||||
return str.replaceAll(rAllWhiteSpace, ' ').trim();
|
||||
}
|
||||
return str;
|
||||
};
|
||||
|
||||
const convertDateToISO8601 = (date: string | Date | number) => {
|
||||
const convertDateToISO8601 = (date?: string | Date | number | null) => {
|
||||
if (!date) {
|
||||
return date;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue