1
0
mirror of https://github.com/laurent22/joplin.git synced 2024-12-18 09:35:20 +02:00
joplin/packages/tools/utils/discourse.test.ts

19 lines
612 B
TypeScript
Raw Normal View History

2024-11-09 14:44:12 +02:00
import { trimPostToMaximumLength } from './discourse';
describe('utils/discourse', () => {
it('trimPostToMaximumLength should allow trimming posts to a maximum length', () => {
const makeLongString = (length: number) => {
const resultParts = [];
while (resultParts.length < length) {
resultParts.push('1');
}
return resultParts.join('');
};
const longContent = makeLongString(70_000);
const trimmed = trimPostToMaximumLength(longContent);
expect(trimmed.length).toBeLessThan(65_000);
expect(trimmed).toContain(`${longContent.substring(0, 65_000 - 153)}...\n\n**Note**:`);
});
});