2022-12-27 03:54:51 +00:00
|
|
|
import {
|
|
|
|
convertSecondsToFormattedDateString,
|
2023-01-05 19:59:59 +00:00
|
|
|
isInteger,
|
2022-12-27 03:54:51 +00:00
|
|
|
slugifyString,
|
|
|
|
underscorizeString,
|
|
|
|
} from './helpers';
|
2022-10-12 14:21:49 +00:00
|
|
|
|
|
|
|
test('it can slugify a string', () => {
|
|
|
|
expect(slugifyString('hello---world_ and then Some such-')).toEqual(
|
|
|
|
'hello-world-and-then-some-such'
|
|
|
|
);
|
|
|
|
});
|
2022-11-09 19:51:22 +00:00
|
|
|
|
2022-12-27 03:54:51 +00:00
|
|
|
test('it can underscorize a string', () => {
|
|
|
|
expect(underscorizeString('hello---world_ and then Some such-')).toEqual(
|
|
|
|
'hello_world_and_then_some_such'
|
|
|
|
);
|
|
|
|
});
|
|
|
|
|
2022-11-09 19:51:22 +00:00
|
|
|
test('it can keep the correct date when converting seconds to date', () => {
|
2022-11-17 20:03:11 +00:00
|
|
|
const dateString = convertSecondsToFormattedDateString(1666325400);
|
2022-11-09 19:51:22 +00:00
|
|
|
expect(dateString).toEqual('2022-10-21');
|
|
|
|
});
|
2023-01-05 19:59:59 +00:00
|
|
|
|
|
|
|
test('it can validate numeric values', () => {
|
|
|
|
expect(isInteger('11')).toEqual(true);
|
|
|
|
expect(isInteger('hey')).toEqual(false);
|
|
|
|
expect(isInteger(' ')).toEqual(false);
|
|
|
|
expect(isInteger('1 2')).toEqual(false);
|
|
|
|
expect(isInteger(2)).toEqual(true);
|
|
|
|
});
|