diff --git a/src/presets/semver-workflow.ts b/src/presets/semver-workflow.ts index 8ba299a9..47e2ec7d 100644 --- a/src/presets/semver-workflow.ts +++ b/src/presets/semver-workflow.ts @@ -147,7 +147,7 @@ function closeEnough(a: string, b: string) { const bLines = b.split('\n') const matchingLines = aLines.filter((line) => bLines.find((bLine) => bLine === line)).length - const isCloseEnough = matchingLines > aLines.length * 0.5 + const isCloseEnough = matchingLines >= aLines.length * 0.5 return isCloseEnough } diff --git a/test/semver-workflow.test.ts b/test/semver-workflow.test.ts index f7231d96..7a09cc67 100644 --- a/test/semver-workflow.test.ts +++ b/test/semver-workflow.test.ts @@ -2,6 +2,7 @@ import tap from 'tap' import {missingSections, readmeBaseurl} from '../src/presets/semver-workflow' import {PackageJson} from '../src/actions/verify/types' import outdent from 'outdent' +import {getLicenseText} from '../src/util/readme' tap.test('readmeBaseUrl', async (t) => { const testCases: {pkg: PackageJson; expectedUrl: string}[] = [ @@ -36,18 +37,29 @@ tap.test('missingSections', async (t) => { matches b exactly c ` + + const exactMatch2 = getLicenseText('MIT', {name: 'yolo'}) + const over50PercentMatch = outdent` This x matches y enough z ` - const only50PercentMatch = outdent` + const fiftyPercentMatch = outdent` This does - not + barely + match +` + + const lessThan50PercentMatch = outdent` + This not + does not + not not match ` - const sections = [exactMatch, over50PercentMatch, only50PercentMatch] + + const sections = [exactMatch, over50PercentMatch, fiftyPercentMatch, lessThan50PercentMatch] const readme = outdent` This a @@ -58,11 +70,19 @@ tap.test('missingSections', async (t) => { matches y enough zzzzzz + This + does + barely + match + This does miss + + ${exactMatch2} + ` const missing = missingSections(readme, sections) - t.same(missing, [only50PercentMatch]) + t.same(missing, [lessThan50PercentMatch]) })