2022-03-03 09:35:26 +00:00
|
|
|
import { Fixtures } from '../../../../test/fixtures';
|
2020-03-05 20:57:24 +00:00
|
|
|
import { smartTruncate } from './pr-body';
|
2019-09-25 10:42:11 +00:00
|
|
|
|
2022-01-23 21:23:54 +00:00
|
|
|
const prBody = Fixtures.get('pr-body.txt');
|
2021-04-23 16:58:48 +00:00
|
|
|
|
2022-03-03 09:35:26 +00:00
|
|
|
describe('modules/platform/utils/pr-body', () => {
|
2019-09-25 10:42:11 +00:00
|
|
|
describe('.smartTruncate', () => {
|
|
|
|
it('truncates to 1000', () => {
|
|
|
|
const body = smartTruncate(prBody, 1000);
|
|
|
|
expect(body).toMatchSnapshot();
|
2021-11-08 12:16:58 +00:00
|
|
|
expect(body.length < prBody.length).toBe(true);
|
2019-09-25 10:42:11 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
it('truncates to 300 not smart', () => {
|
|
|
|
const body = smartTruncate(prBody, 300);
|
|
|
|
expect(body).toMatchSnapshot();
|
2020-05-18 12:33:44 +00:00
|
|
|
expect(body).toHaveLength(300);
|
2019-09-25 10:42:11 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
it('truncates to 10', () => {
|
|
|
|
const body = smartTruncate('Lorem ipsum dolor sit amet', 10);
|
2021-11-08 12:16:58 +00:00
|
|
|
expect(body).toBe('Lorem ipsu');
|
2019-09-25 10:42:11 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
it('does not truncate', () => {
|
|
|
|
expect(smartTruncate(prBody, 60000)).toEqual(prBody);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|