mirror of
https://github.com/CorentinTh/it-tools.git
synced 2025-05-04 13:29:13 -04:00
Fix type checking issues
This commit is contained in:
parent
d75473b2e8
commit
7e90365657
3 changed files with 9 additions and 9 deletions
|
@ -43,7 +43,7 @@ describe('text-to-unicode', () => {
|
|||
interface TestConfig {
|
||||
text: string
|
||||
results: Record<ConverterId, string>
|
||||
skipPrintableAscii?: boolean
|
||||
skipAscii?: boolean
|
||||
};
|
||||
const tests: TestConfig[] = [
|
||||
{
|
||||
|
@ -57,7 +57,7 @@ describe('text-to-unicode', () => {
|
|||
},
|
||||
{
|
||||
text: 'ABC',
|
||||
skipPrintableAscii: true,
|
||||
skipAscii: true,
|
||||
results: {
|
||||
fullUnicode: 'ABC',
|
||||
utf16: 'ABC',
|
||||
|
@ -67,7 +67,7 @@ describe('text-to-unicode', () => {
|
|||
},
|
||||
{
|
||||
text: ALL_PRINTABLE_ASCII,
|
||||
skipPrintableAscii: true,
|
||||
skipAscii: true,
|
||||
results: {
|
||||
// eslint-disable-next-line unicorn/escape-case
|
||||
fullUnicode: String.raw` !\u0022#$%&\u0027()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\u005c]^_${'`'}abcdefghijklmnopqrstuvwxyz{|}~`,
|
||||
|
@ -90,7 +90,7 @@ describe('text-to-unicode', () => {
|
|||
},
|
||||
{
|
||||
text: 'a 💩 b',
|
||||
skipPrintableAscii: true,
|
||||
skipAscii: true,
|
||||
results: {
|
||||
// eslint-disable-next-line unicorn/escape-case
|
||||
fullUnicode: String.raw`a \u{1f4a9} b`,
|
||||
|
@ -102,13 +102,13 @@ describe('text-to-unicode', () => {
|
|||
},
|
||||
];
|
||||
|
||||
for (const { text, skipPrintableAscii: skipAscii, results } of tests) {
|
||||
for (const { text, skipAscii, results } of tests) {
|
||||
describe(`${text} (skipAscii=${skipAscii})`, () => {
|
||||
for (const [key, result] of Object.entries(results)) {
|
||||
describe(key, () => {
|
||||
const converter = converters[key as ConverterId];
|
||||
it('Escaping', () => {
|
||||
expect(converter.escape(text, skipAscii)).toBe(result);
|
||||
expect(converter.escape(text, skipAscii ?? false)).toBe(result);
|
||||
});
|
||||
it('Unescaping', () => {
|
||||
expect(converter.unescape(result)).toBe(text);
|
||||
|
|
|
@ -4,11 +4,11 @@ export const SKIP_ASCII_JS = /([ -!#-&(-\[\]-~]+)/g;
|
|||
export const SKIP_ASCII_HTML = /([ -!#-%(-;=?-~]+)/g;
|
||||
|
||||
function codeUnits(text: string): number[] {
|
||||
return text.split('').map(char => char.codePointAt(0));
|
||||
return text.split('').map(char => char.codePointAt(0)!);
|
||||
}
|
||||
|
||||
function codePoints(text: string): number[] {
|
||||
return [...text].map(char => char.codePointAt(0));
|
||||
return [...text].map(char => char.codePointAt(0)!);
|
||||
}
|
||||
|
||||
interface ConverterConfig {
|
||||
|
|
|
@ -27,7 +27,7 @@ const { copy: copyText } = useCopy({ source: textFromUnicode });
|
|||
v-model:value="converterId"
|
||||
searchable
|
||||
label="Conversion type:"
|
||||
:options="Object.entries(converters).map(([key, val]) => ({ label: val.name, value: key }))"
|
||||
:options="Object.entries(converters).map(([key, val]) => ({ label: val.config.name, value: key }))"
|
||||
/>
|
||||
</div>
|
||||
<c-card class="card" title="Text to Unicode">
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue