Skip to content

Commit

Permalink
Port strings update from upstream removing multiline content/tooltips…
Browse files Browse the repository at this point in the history
… (can confirm they didn't work)

Remove non-existant tooltipOverrideLong props
  • Loading branch information
Drulikar committed May 17, 2024
1 parent a8ee006 commit 45b9453
Show file tree
Hide file tree
Showing 6 changed files with 216 additions and 296 deletions.
73 changes: 0 additions & 73 deletions tgui/packages/common/string.babel-plugin.cjs

This file was deleted.

196 changes: 0 additions & 196 deletions tgui/packages/common/string.js

This file was deleted.

35 changes: 35 additions & 0 deletions tgui/packages/common/string.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import { createSearch, decodeHtmlEntities, toTitleCase } from './string';

describe('createSearch', () => {
it('matches search terms correctly', () => {
const search = createSearch('test', (obj: { value: string }) => obj.value);

const obj1 = { value: 'This is a test string.' };
const obj2 = { value: 'This is a different string.' };
const obj3 = { value: 'This is a test string.' };

const objects = [obj1, obj2, obj3];

expect(objects.filter(search)).toEqual([obj1, obj3]);
});
});

describe('toTitleCase', () => {
it('converts strings to title case correctly', () => {
expect(toTitleCase('hello world')).toBe('Hello World');
expect(toTitleCase('HELLO WORLD')).toBe('Hello World');
expect(toTitleCase('HeLLo wORLd')).toBe('Hello World');
expect(toTitleCase('a tale of two cities')).toBe('A Tale of Two Cities');
expect(toTitleCase('war and peace')).toBe('War and Peace');
});
});

describe('decodeHtmlEntities', () => {
it('decodes HTML entities and removes unnecessary HTML tags correctly', () => {
expect(decodeHtmlEntities('<br>')).toBe('\n');
expect(decodeHtmlEntities('<p>Hello World</p>')).toBe('Hello World');
expect(decodeHtmlEntities('&amp;')).toBe('&');
expect(decodeHtmlEntities('&#38;')).toBe('&');
expect(decodeHtmlEntities('&#x26;')).toBe('&');
});
});
Loading

0 comments on commit 45b9453

Please sign in to comment.