diff --git a/lib/platform/azure/index.ts b/lib/platform/azure/index.ts index 0d7485f93ecd32681650eb24c9b40aed0a108185..677bb7f05e4690888be944b83dda7f3c7132f1a5 100644 --- a/lib/platform/azure/index.ts +++ b/lib/platform/azure/index.ts @@ -6,6 +6,7 @@ import GitStorage from '../git/storage'; import { logger } from '../../logger'; import { PlatformConfig, RepoParams, RepoConfig } from '../common'; import { sanitize } from '../../util/sanitize'; +import { smartTruncate } from '../utils/pr-body'; interface Config { storage: GitStorage; @@ -487,7 +488,7 @@ export async function mergePr(pr: number) { export function getPrBody(input: string) { // Remove any HTML we use - return input + return smartTruncate(input, 4000) .replace(new RegExp(`\n---\n\n.*?<!-- ${appSlug}-rebase -->.*?\n`), '') .replace('<summary>', '**') .replace('</summary>', '**') diff --git a/lib/platform/bitbucket-server/index.ts b/lib/platform/bitbucket-server/index.ts index 02db3b56f71c699099d23122ff068b77f8189753..138b3a509b382f9231dd226657bd0f8b33e8ff4b 100644 --- a/lib/platform/bitbucket-server/index.ts +++ b/lib/platform/bitbucket-server/index.ts @@ -8,6 +8,7 @@ import GitStorage from '../git/storage'; import { logger } from '../../logger'; import { PlatformConfig, RepoParams, RepoConfig } from '../common'; import { sanitize } from '../../util/sanitize'; +import { smartTruncate } from '../utils/pr-body'; /* * Version: 5.3 (EOL Date: 15 Aug 2019) @@ -952,12 +953,11 @@ export async function mergePr(prNo: number, branchName: string) { export function getPrBody(input: string) { logger.debug(`getPrBody(${input.split('\n')[0]})`); // Remove any HTML we use - return input + return smartTruncate(input, 30000) .replace(/<\/?summary>/g, '**') .replace(/<\/?details>/g, '') .replace(new RegExp(`\n---\n\n.*?<!-- .*?-rebase -->.*?(\n|$)`), '') - .replace(new RegExp('<!--.*?-->', 'g'), '') - .substring(0, 30000); + .replace(new RegExp('<!--.*?-->', 'g'), ''); } export function getCommitMessages() { diff --git a/lib/platform/bitbucket/index.ts b/lib/platform/bitbucket/index.ts index f4a1c886923b37a8d96c63e902c68c7b2926f0ae..db3d2908b979bb7b332082ee0861bb6e77974be0 100644 --- a/lib/platform/bitbucket/index.ts +++ b/lib/platform/bitbucket/index.ts @@ -10,6 +10,7 @@ import { appSlug } from '../../config/app-strings'; import * as comments from './comments'; import { PlatformConfig, RepoParams, RepoConfig } from '../common'; import { sanitize } from '../../util/sanitize'; +import { smartTruncate } from '../utils/pr-body'; let config: utils.Config = {} as any; @@ -694,12 +695,11 @@ export async function mergePr(prNo: number, branchName: string) { export function getPrBody(input: string) { // Remove any HTML we use - return input + return smartTruncate(input, 50000) .replace(/<\/?summary>/g, '**') .replace(/<\/?details>/g, '') .replace(new RegExp(`\n---\n\n.*?<!-- ${appSlug}-rebase -->.*?\n`), '') - .replace(/\]\(\.\.\/pull\//g, '](../../pull-requests/') - .substring(0, 50000); + .replace(/\]\(\.\.\/pull\//g, '](../../pull-requests/'); } // Return the commit SHA for a branch diff --git a/lib/platform/github/index.ts b/lib/platform/github/index.ts index 3b9a7580f3d5b89694a1914a83bc612d0c25c45e..2baa8a5e018d8688daa2ce096220f9b2dca1756d 100644 --- a/lib/platform/github/index.ts +++ b/lib/platform/github/index.ts @@ -16,6 +16,7 @@ import { urls, } from '../../config/app-strings'; import { sanitize } from '../../util/sanitize'; +import { smartTruncate } from '../utils/pr-body'; const defaultConfigFile = configFileNames[0]; @@ -1711,39 +1712,16 @@ export async function mergePr(prNo: number, branchName: string) { return true; } -// istanbul ignore next -function smartTruncate(input: string) { - if (input.length < 60000) { - return input; - } - const releaseNotesMatch = input.match( - new RegExp(`### Release Notes.*### ${appName} configuration`, 'ms') - ); - // istanbul ignore if - if (releaseNotesMatch) { - const divider = `</details>\n\n---\n\n### ${appName} configuration`; - const [releaseNotes] = releaseNotesMatch; - const nonReleaseNotesLength = - input.length - releaseNotes.length - divider.length; - const availableLength = 60000 - nonReleaseNotesLength; - return input.replace( - releaseNotes, - releaseNotes.slice(0, availableLength) + divider - ); - } - return input.substring(0, 60000); -} - export function getPrBody(input: string) { if (config.isGhe) { - return smartTruncate(input); + return smartTruncate(input, 60000); } const massagedInput = input // to be safe, replace all github.com links with renovatebot redirector .replace(/href="https?:\/\/github.com\//g, 'href="https://togithub.com/') .replace(/]\(https:\/\/github\.com\//g, '](https://togithub.com/') .replace(/]: https:\/\/github\.com\//g, ']: https://togithub.com/'); - return smartTruncate(massagedInput); + return smartTruncate(massagedInput, 60000); } export async function getVulnerabilityAlerts() { diff --git a/lib/platform/gitlab/index.ts b/lib/platform/gitlab/index.ts index 3e47de1557934467b94efc357e60bd4f047d3b91..b780d0b6676bea7d09faa962603ecfc32360c326 100644 --- a/lib/platform/gitlab/index.ts +++ b/lib/platform/gitlab/index.ts @@ -8,6 +8,7 @@ import { PlatformConfig, RepoParams, RepoConfig } from '../common'; import { configFileNames } from '../../config/app-strings'; import { logger } from '../../logger'; import { sanitize } from '../../util/sanitize'; +import { smartTruncate } from '../utils/pr-body'; const defaultConfigFile = configFileNames[0]; let config: { @@ -830,10 +831,13 @@ export async function mergePr(iid: number) { } export function getPrBody(input: string) { - return input - .replace(/Pull Request/g, 'Merge Request') - .replace(/PR/g, 'MR') - .replace(/\]\(\.\.\/pull\//g, '](../merge_requests/'); + return smartTruncate( + input + .replace(/Pull Request/g, 'Merge Request') + .replace(/PR/g, 'MR') + .replace(/\]\(\.\.\/pull\//g, '](../merge_requests/'), + 1000000 + ); } export function getCommitMessages() { diff --git a/lib/platform/utils/pr-body.ts b/lib/platform/utils/pr-body.ts new file mode 100644 index 0000000000000000000000000000000000000000..7158c7b9161a192eadd9156e76c9f09c462f2590 --- /dev/null +++ b/lib/platform/utils/pr-body.ts @@ -0,0 +1,23 @@ +import { appName } from '../../config/app-strings'; + +export function smartTruncate(input: string, len: number): string { + if (input.length < len) { + return input; + } + const releaseNotesMatch = input.match( + new RegExp(`### Release Notes.*### ${appName} configuration`, 'ms') + ); + if (releaseNotesMatch) { + const divider = `</details>\n\n---\n\n### ${appName} configuration`; + const [releaseNotes] = releaseNotesMatch; + const nonReleaseNotesLength = + input.length - releaseNotes.length - divider.length; + const availableLength = len - nonReleaseNotesLength; + if (availableLength <= 0) return input.substring(0, len); + return input.replace( + releaseNotes, + releaseNotes.slice(0, availableLength) + divider + ); + } + return input.substring(0, len); +} diff --git a/test/platform/utils/__snapshots__/pr-body.spec.ts.snap b/test/platform/utils/__snapshots__/pr-body.spec.ts.snap new file mode 100644 index 0000000000000000000000000000000000000000..e96d6b3a905612fa84f79e7fb80e8c5161a1f662 --- /dev/null +++ b/test/platform/utils/__snapshots__/pr-body.spec.ts.snap @@ -0,0 +1,60 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`platform/utils/pr-body .smartTruncate truncates to 300 not smart 1`] = ` +"This PR contains the following updates: + +| Package | Type | Update | Change | +|---|---|---|---| +| [renovate/renovate](https://togithub.com/renovatebot/renovate) | final | minor | \`19.46.0-slim\` -> \`19.47.0-slim\` | + +--- + +### Release Notes + +<details> +<summary>renovatebot/renovate</summary> + +### [\`v19." +`; + +exports[`platform/utils/pr-body .smartTruncate truncates to 1000 1`] = ` +"This PR contains the following updates: + +| Package | Type | Update | Change | +|---|---|---|---| +| [renovate/renovate](https://togithub.com/renovatebot/renovate) | final | minor | \`19.46.0-slim\` -> \`19.47.0-slim\` | + +--- + +### Release Notes + +<details> +<summary>renovatebot/renovate</summary> + +### [\`v19.47.0\`](https://togithub.com/renovatebot/renovate/releases/19.47.0) + +##### Features + +- **docker:** AWS ECR authentication support ([#​4497](https://togi</details> + +--- + +### Renovate configuration + +:date: **Schedule**: At any time (no schedule defined). + +:vertical_traffic_light: **Automerge**: Enabled. + +:recycle: **Rebasing**: Whenever PR becomes conflicted, or if you modify the PR title to begin with \\"\`rebase!\`\\". + +:no_bell: **Ignore**: Close this PR and you won't be reminded about this update again. + +--- + + - [ ] <!-- renovate-rebase -->If you want to rebase/retry this PR, check this box + +--- + +This PR has been generated by [Renovate Bot](https://togithub.com/marketplace/renovate). View repository job log [here](https://renovatebot.com/dashboard#VisualOn/docker-images). +" +`; diff --git a/test/platform/utils/_fixtures/pr-body.txt b/test/platform/utils/_fixtures/pr-body.txt new file mode 100644 index 0000000000000000000000000000000000000000..44c2bdc3e052ec4142bd96da6bb19173141c5d7a --- /dev/null +++ b/test/platform/utils/_fixtures/pr-body.txt @@ -0,0 +1,101 @@ +This PR contains the following updates: + +| Package | Type | Update | Change | +|---|---|---|---| +| [renovate/renovate](https://togithub.com/renovatebot/renovate) | final | minor | `19.46.0-slim` -> `19.47.0-slim` | + +--- + +### Release Notes + +<details> +<summary>renovatebot/renovate</summary> + +### [`v19.47.0`](https://togithub.com/renovatebot/renovate/releases/19.47.0) + +##### Features + +- **docker:** AWS ECR authentication support ([#​4497](https://togithub.com/renovatebot/renovate/issues/4497)) ([acb114a](https://togithub.com/renovatebot/renovate/commit/acb114a)) +- **docker:** AWS ECR authentication support ([#​4497](https://togithub.com/renovatebot/renovate/issues/4497)) ([acb114a](https://togithub.com/renovatebot/renovate/commit/acb114a)) +- **docker:** AWS ECR authentication support ([#​4497](https://togithub.com/renovatebot/renovate/issues/4497)) ([acb114a](https://togithub.com/renovatebot/renovate/commit/acb114a)) +- **docker:** AWS ECR authentication support ([#​4497](https://togithub.com/renovatebot/renovate/issues/4497)) ([acb114a](https://togithub.com/renovatebot/renovate/commit/acb114a)) +- **docker:** AWS ECR authentication support ([#​4497](https://togithub.com/renovatebot/renovate/issues/4497)) ([acb114a](https://togithub.com/renovatebot/renovate/commit/acb114a)) +- **docker:** AWS ECR authentication support ([#​4497](https://togithub.com/renovatebot/renovate/issues/4497)) ([acb114a](https://togithub.com/renovatebot/renovate/commit/acb114a)) +- **docker:** AWS ECR authentication support ([#​4497](https://togithub.com/renovatebot/renovate/issues/4497)) ([acb114a](https://togithub.com/renovatebot/renovate/commit/acb114a)) +- **docker:** AWS ECR authentication support ([#​4497](https://togithub.com/renovatebot/renovate/issues/4497)) ([acb114a](https://togithub.com/renovatebot/renovate/commit/acb114a)) +- **docker:** AWS ECR authentication support ([#​4497](https://togithub.com/renovatebot/renovate/issues/4497)) ([acb114a](https://togithub.com/renovatebot/renovate/commit/acb114a)) +- **docker:** AWS ECR authentication support ([#​4497](https://togithub.com/renovatebot/renovate/issues/4497)) ([acb114a](https://togithub.com/renovatebot/renovate/commit/acb114a)) +- **docker:** AWS ECR authentication support ([#​4497](https://togithub.com/renovatebot/renovate/issues/4497)) ([acb114a](https://togithub.com/renovatebot/renovate/commit/acb114a)) +- **docker:** AWS ECR authentication support ([#​4497](https://togithub.com/renovatebot/renovate/issues/4497)) ([acb114a](https://togithub.com/renovatebot/renovate/commit/acb114a)) +- **docker:** AWS ECR authentication support ([#​4497](https://togithub.com/renovatebot/renovate/issues/4497)) ([acb114a](https://togithub.com/renovatebot/renovate/commit/acb114a)) +- **docker:** AWS ECR authentication support ([#​4497](https://togithub.com/renovatebot/renovate/issues/4497)) ([acb114a](https://togithub.com/renovatebot/renovate/commit/acb114a)) +- **docker:** AWS ECR authentication support ([#​4497](https://togithub.com/renovatebot/renovate/issues/4497)) ([acb114a](https://togithub.com/renovatebot/renovate/commit/acb114a)) +- **docker:** AWS ECR authentication support ([#​4497](https://togithub.com/renovatebot/renovate/issues/4497)) ([acb114a](https://togithub.com/renovatebot/renovate/commit/acb114a)) +- **docker:** AWS ECR authentication support ([#​4497](https://togithub.com/renovatebot/renovate/issues/4497)) ([acb114a](https://togithub.com/renovatebot/renovate/commit/acb114a)) +- **docker:** AWS ECR authentication support ([#​4497](https://togithub.com/renovatebot/renovate/issues/4497)) ([acb114a](https://togithub.com/renovatebot/renovate/commit/acb114a)) +- **docker:** AWS ECR authentication support ([#​4497](https://togithub.com/renovatebot/renovate/issues/4497)) ([acb114a](https://togithub.com/renovatebot/renovate/commit/acb114a)) +- **docker:** AWS ECR authentication support ([#​4497](https://togithub.com/renovatebot/renovate/issues/4497)) ([acb114a](https://togithub.com/renovatebot/renovate/commit/acb114a)) +- **docker:** AWS ECR authentication support ([#​4497](https://togithub.com/renovatebot/renovate/issues/4497)) ([acb114a](https://togithub.com/renovatebot/renovate/commit/acb114a)) +- **docker:** AWS ECR authentication support ([#​4497](https://togithub.com/renovatebot/renovate/issues/4497)) ([acb114a](https://togithub.com/renovatebot/renovate/commit/acb114a)) +- **docker:** AWS ECR authentication support ([#​4497](https://togithub.com/renovatebot/renovate/issues/4497)) ([acb114a](https://togithub.com/renovatebot/renovate/commit/acb114a)) +- **docker:** AWS ECR authentication support ([#​4497](https://togithub.com/renovatebot/renovate/issues/4497)) ([acb114a](https://togithub.com/renovatebot/renovate/commit/acb114a)) +- **docker:** AWS ECR authentication support ([#​4497](https://togithub.com/renovatebot/renovate/issues/4497)) ([acb114a](https://togithub.com/renovatebot/renovate/commit/acb114a)) +- **docker:** AWS ECR authentication support ([#​4497](https://togithub.com/renovatebot/renovate/issues/4497)) ([acb114a](https://togithub.com/renovatebot/renovate/commit/acb114a)) +- **docker:** AWS ECR authentication support ([#​4497](https://togithub.com/renovatebot/renovate/issues/4497)) ([acb114a](https://togithub.com/renovatebot/renovate/commit/acb114a)) +- **docker:** AWS ECR authentication support ([#​4497](https://togithub.com/renovatebot/renovate/issues/4497)) ([acb114a](https://togithub.com/renovatebot/renovate/commit/acb114a)) +- **docker:** AWS ECR authentication support ([#​4497](https://togithub.com/renovatebot/renovate/issues/4497)) ([acb114a](https://togithub.com/renovatebot/renovate/commit/acb114a)) +- **docker:** AWS ECR authentication support ([#​4497](https://togithub.com/renovatebot/renovate/issues/4497)) ([acb114a](https://togithub.com/renovatebot/renovate/commit/acb114a)) +- **docker:** AWS ECR authentication support ([#​4497](https://togithub.com/renovatebot/renovate/issues/4497)) ([acb114a](https://togithub.com/renovatebot/renovate/commit/acb114a)) +- **docker:** AWS ECR authentication support ([#​4497](https://togithub.com/renovatebot/renovate/issues/4497)) ([acb114a](https://togithub.com/renovatebot/renovate/commit/acb114a)) +- **docker:** AWS ECR authentication support ([#​4497](https://togithub.com/renovatebot/renovate/issues/4497)) ([acb114a](https://togithub.com/renovatebot/renovate/commit/acb114a)) +- **docker:** AWS ECR authentication support ([#​4497](https://togithub.com/renovatebot/renovate/issues/4497)) ([acb114a](https://togithub.com/renovatebot/renovate/commit/acb114a)) +- **docker:** AWS ECR authentication support ([#​4497](https://togithub.com/renovatebot/renovate/issues/4497)) ([acb114a](https://togithub.com/renovatebot/renovate/commit/acb114a)) +- **docker:** AWS ECR authentication support ([#​4497](https://togithub.com/renovatebot/renovate/issues/4497)) ([acb114a](https://togithub.com/renovatebot/renovate/commit/acb114a)) +- **docker:** AWS ECR authentication support ([#​4497](https://togithub.com/renovatebot/renovate/issues/4497)) ([acb114a](https://togithub.com/renovatebot/renovate/commit/acb114a)) +- **docker:** AWS ECR authentication support ([#​4497](https://togithub.com/renovatebot/renovate/issues/4497)) ([acb114a](https://togithub.com/renovatebot/renovate/commit/acb114a)) +- **docker:** AWS ECR authentication support ([#​4497](https://togithub.com/renovatebot/renovate/issues/4497)) ([acb114a](https://togithub.com/renovatebot/renovate/commit/acb114a)) +- **docker:** AWS ECR authentication support ([#​4497](https://togithub.com/renovatebot/renovate/issues/4497)) ([acb114a](https://togithub.com/renovatebot/renovate/commit/acb114a)) +- **docker:** AWS ECR authentication support ([#​4497](https://togithub.com/renovatebot/renovate/issues/4497)) ([acb114a](https://togithub.com/renovatebot/renovate/commit/acb114a)) +- **docker:** AWS ECR authentication support ([#​4497](https://togithub.com/renovatebot/renovate/issues/4497)) ([acb114a](https://togithub.com/renovatebot/renovate/commit/acb114a)) +- **docker:** AWS ECR authentication support ([#​4497](https://togithub.com/renovatebot/renovate/issues/4497)) ([acb114a](https://togithub.com/renovatebot/renovate/commit/acb114a)) +- **docker:** AWS ECR authentication support ([#​4497](https://togithub.com/renovatebot/renovate/issues/4497)) ([acb114a](https://togithub.com/renovatebot/renovate/commit/acb114a)) +- **docker:** AWS ECR authentication support ([#​4497](https://togithub.com/renovatebot/renovate/issues/4497)) ([acb114a](https://togithub.com/renovatebot/renovate/commit/acb114a)) +- **docker:** AWS ECR authentication support ([#​4497](https://togithub.com/renovatebot/renovate/issues/4497)) ([acb114a](https://togithub.com/renovatebot/renovate/commit/acb114a)) +- **docker:** AWS ECR authentication support ([#​4497](https://togithub.com/renovatebot/renovate/issues/4497)) ([acb114a](https://togithub.com/renovatebot/renovate/commit/acb114a)) +- **docker:** AWS ECR authentication support ([#​4497](https://togithub.com/renovatebot/renovate/issues/4497)) ([acb114a](https://togithub.com/renovatebot/renovate/commit/acb114a)) +- **docker:** AWS ECR authentication support ([#​4497](https://togithub.com/renovatebot/renovate/issues/4497)) ([acb114a](https://togithub.com/renovatebot/renovate/commit/acb114a)) +- **docker:** AWS ECR authentication support ([#​4497](https://togithub.com/renovatebot/renovate/issues/4497)) ([acb114a](https://togithub.com/renovatebot/renovate/commit/acb114a)) +- **docker:** AWS ECR authentication support ([#​4497](https://togithub.com/renovatebot/renovate/issues/4497)) ([acb114a](https://togithub.com/renovatebot/renovate/commit/acb114a)) +- **docker:** AWS ECR authentication support ([#​4497](https://togithub.com/renovatebot/renovate/issues/4497)) ([acb114a](https://togithub.com/renovatebot/renovate/commit/acb114a)) +- **docker:** AWS ECR authentication support ([#​4497](https://togithub.com/renovatebot/renovate/issues/4497)) ([acb114a](https://togithub.com/renovatebot/renovate/commit/acb114a)) +- **docker:** AWS ECR authentication support ([#​4497](https://togithub.com/renovatebot/renovate/issues/4497)) ([acb114a](https://togithub.com/renovatebot/renovate/commit/acb114a)) +- **docker:** AWS ECR authentication support ([#​4497](https://togithub.com/renovatebot/renovate/issues/4497)) ([acb114a](https://togithub.com/renovatebot/renovate/commit/acb114a)) +- **docker:** AWS ECR authentication support ([#​4497](https://togithub.com/renovatebot/renovate/issues/4497)) ([acb114a](https://togithub.com/renovatebot/renovate/commit/acb114a)) +- **docker:** AWS ECR authentication support ([#​4497](https://togithub.com/renovatebot/renovate/issues/4497)) ([acb114a](https://togithub.com/renovatebot/renovate/commit/acb114a)) +- **docker:** AWS ECR authentication support ([#​4497](https://togithub.com/renovatebot/renovate/issues/4497)) ([acb114a](https://togithub.com/renovatebot/renovate/commit/acb114a)) +- **docker:** AWS ECR authentication support ([#​4497](https://togithub.com/renovatebot/renovate/issues/4497)) ([acb114a](https://togithub.com/renovatebot/renovate/commit/acb114a)) +- **docker:** AWS ECR authentication support ([#​4497](https://togithub.com/renovatebot/renovate/issues/4497)) ([acb114a](https://togithub.com/renovatebot/renovate/commit/acb114a)) +- **docker:** AWS ECR authentication support ([#​4497](https://togithub.com/renovatebot/renovate/issues/4497)) ([acb114a](https://togithub.com/renovatebot/renovate/commit/acb114a)) +- **docker:** AWS ECR authentication support ([#​4497](https://togithub.com/renovatebot/renovate/issues/4497)) ([acb114a](https://togithub.com/renovatebot/renovate/commit/acb114a)) + +</details> + +--- + +### Renovate configuration + +:date: **Schedule**: At any time (no schedule defined). + +:vertical_traffic_light: **Automerge**: Enabled. + +:recycle: **Rebasing**: Whenever PR becomes conflicted, or if you modify the PR title to begin with "`rebase!`". + +:no_bell: **Ignore**: Close this PR and you won't be reminded about this update again. + +--- + + - [ ] <!-- renovate-rebase -->If you want to rebase/retry this PR, check this box + +--- + +This PR has been generated by [Renovate Bot](https://togithub.com/marketplace/renovate). View repository job log [here](https://renovatebot.com/dashboard#VisualOn/docker-images). diff --git a/test/platform/utils/pr-body.spec.ts b/test/platform/utils/pr-body.spec.ts new file mode 100644 index 0000000000000000000000000000000000000000..77792e176afbe7d5ff244190f4ebc05a77169bb6 --- /dev/null +++ b/test/platform/utils/pr-body.spec.ts @@ -0,0 +1,34 @@ +import fs from 'fs-extra'; +import { smartTruncate } from '../../../lib/platform/utils/pr-body'; + +describe('platform/utils/pr-body', () => { + let prBody: string; + beforeAll(async () => { + prBody = await fs.readFile( + 'test/platform/utils/_fixtures/pr-body.txt', + 'utf8' + ); + }); + describe('.smartTruncate', () => { + it('truncates to 1000', () => { + const body = smartTruncate(prBody, 1000); + expect(body).toMatchSnapshot(); + expect(body.length < prBody.length).toEqual(true); + }); + + it('truncates to 300 not smart', () => { + const body = smartTruncate(prBody, 300); + expect(body).toMatchSnapshot(); + expect(body.length).toEqual(300); + }); + + it('truncates to 10', () => { + const body = smartTruncate('Lorem ipsum dolor sit amet', 10); + expect(body).toEqual('Lorem ipsu'); + }); + + it('does not truncate', () => { + expect(smartTruncate(prBody, 60000)).toEqual(prBody); + }); + }); +});