Skip to content

Commit 5d30f24

Browse files
author
Gary Lockett
committed
add failing test for larger than 0 patch number
Signed-off-by: Gary Lockett <[email protected]>
1 parent 8459e92 commit 5d30f24

File tree

2 files changed

+23
-3
lines changed

2 files changed

+23
-3
lines changed

src/config/app.spec.ts

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,27 @@
11
import {PathLike} from 'fs';
2-
import createConfig from './app';
2+
import createConfig, {gatherVersions} from './app';
33

44
describe('config/app', () => {
5+
describe('gatherVersions()', () => {
6+
test.each`
7+
constraint | expected
8+
${'7.0'} | ${[ '7.0' ]}
9+
${'^7.0'} | ${[ '7.0', '7.1', '7.2', '7.3', '7.4' ]}
10+
${'8.1'} | ${[ '8.1' ]}
11+
${'8.1.0'} | ${[ '8.1' ]}
12+
${'8.1.12'} | ${[ '8.1' ]}
13+
${'^8.1'} | ${[ '8.1', '8.2' ]}
14+
${'^8.1.0'} | ${[ '8.1', '8.2' ]}
15+
${'^8.1.12'} | ${[ '8.1', '8.2' ]}
16+
${'~8.1'} | ${[ '8.1' ]}
17+
${'~8.1.0'} | ${[ '8.1' ]}
18+
${'~8.1.12'} | ${[ '8.1' ]}
19+
${'^7.4 || ~8.0.0 || ~8.1.12'} | ${[ '7.4', '8.0', '8.1' ]}
20+
`('gatherVersions() for "$constraint" === $expected', ({constraint, expected}) => {
21+
expect(gatherVersions({require: {php: constraint}})).toEqual(expected);
22+
});
23+
});
24+
525
describe('createConfig()', () => {
626
const phpIniFromConfigurationPath: PathLike = 'tests/php-ini-from-configuration';
727

@@ -18,7 +38,7 @@ describe('config/app', () => {
1838
codeChecks : true,
1939
docLinting : true,
2040
versions : [ '8.1' ],
21-
stablePhpVersion : '8.1',
41+
stablePhpVersion : '7.4',
2242
minimumPhpVersion : '8.1',
2343
latestPhpVersion : '8.1',
2444
lockedDependenciesExists : false,

src/config/app.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ export enum ComposerDependencySet {
1616
LATEST = 'latest',
1717
}
1818

19-
function gatherVersions(composerJson: ComposerJson): InstallablePhpVersionType[] {
19+
export function gatherVersions(composerJson: ComposerJson): InstallablePhpVersionType[] {
2020
if (JSON.stringify(composerJson) === '{}') {
2121
return [];
2222
}

0 commit comments

Comments
 (0)