Added StringHelpers, UniqIdGenerators and UrlParser test
UniqIdGenerators skips window.crypt test URL tests need to be more in detail
This commit is contained in:
60
tests/StringHelpers.test.js
Normal file
60
tests/StringHelpers.test.js
Normal file
@@ -0,0 +1,60 @@
|
||||
import { describe, it, expect } from "vitest";
|
||||
|
||||
import {
|
||||
formatString,
|
||||
numberWithCommas,
|
||||
convertLBtoBR
|
||||
} from '../src/utils/StringHelpers.mjs';
|
||||
|
||||
describe("formatString", () => {
|
||||
it('Should replace {n} entries in strings', () => {
|
||||
expect(
|
||||
formatString("{0} is cool, {1} is not", "Alpha", "Beta")
|
||||
).toBe("Alpha is cool, Beta is not");
|
||||
expect(
|
||||
formatString("{0} is cool, {1} is not", "Alpha")
|
||||
).toBe("Alpha is cool, {1} is not");
|
||||
});
|
||||
});
|
||||
|
||||
describe("numberWithCommas", () => {
|
||||
it('Should format a number into a decimal formatted', () => {
|
||||
let numbers_list = [
|
||||
{
|
||||
"in": 123,
|
||||
"out": "123",
|
||||
},
|
||||
{
|
||||
"in": 1234,
|
||||
"out": "1,234"
|
||||
},
|
||||
{
|
||||
"in": 12345,
|
||||
"out": "12,345"
|
||||
},
|
||||
{
|
||||
"in": 123456,
|
||||
"out": "123,456"
|
||||
},
|
||||
{
|
||||
"in": 1234567,
|
||||
"out": "1,234,567"
|
||||
},
|
||||
{
|
||||
"in": 1234567890,
|
||||
"out": "1,234,567,890"
|
||||
},
|
||||
];
|
||||
for (let number of numbers_list) {
|
||||
expect(numberWithCommas(number.in)).toBe(number.out);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
describe("convertLBtoBR", () => {
|
||||
it('Should convert LF/CR to <br>', () => {
|
||||
expect(convertLBtoBR("AB\nCD")).toBe("AB<br>CD");
|
||||
});
|
||||
});
|
||||
|
||||
// __END__
|
||||
Reference in New Issue
Block a user