mirror of
https://github.com/DIYgod/RSSHub.git
synced 2026-09-01 14:57:14 +08:00
test: common-utils
This commit is contained in:
+1
-1
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user