1
0
mirror of https://github.com/badges/shields.git synced 2025-04-18 19:44:04 +03:00
shields/services/php-version.spec.js
dependabot[bot] b9d96755ec
chore(deps-dev): bump prettier from 2.8.8 to 3.0.0 (#9357)
* chore(deps-dev): bump prettier from 2.8.8 to 3.0.0

Bumps [prettier](https://github.com/prettier/prettier) from 2.8.8 to 3.0.0.
- [Release notes](https://github.com/prettier/prettier/releases)
- [Changelog](https://github.com/prettier/prettier/blob/main/CHANGELOG.md)
- [Commits](https://github.com/prettier/prettier/compare/2.8.8...3.0.0)

---
updated-dependencies:
- dependency-name: prettier
  dependency-type: direct:development
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>

* reformat all the things (prettier 3)

* update tests to await calls to prettier.format()

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: chris48s <git@chris-shaw.dev>
2023-07-10 09:27:51 +00:00

85 lines
2.6 KiB
JavaScript

import { test, given } from 'sazerac'
import { compare, minorVersion, versionReduction } from './php-version.js'
const phpReleases = [
'5.0',
'5.1',
'5.2',
'5.3',
'5.4',
'5.5',
'5.6',
'7.0',
'7.1',
'7.2',
]
describe('Text PHP version', function () {
test(minorVersion, () => {
given('7').expect('7.0')
given('7.1').expect('7.1')
given('5.3.3').expect('5.3')
given('hhvm').expect('')
})
test(versionReduction, () => {
given(['5.3', '5.4', '5.5'], phpReleases).expect(['5.3 - 5.5'])
given(['5.4', '5.5', '5.6', '7.0', '7.1'], phpReleases).expect([
'5.4 - 7.1',
])
given(['5.5', '5.6', '7.0', '7.1', '7.2'], phpReleases).expect(['>= 5.5'])
given(['5.5', '5.6', '7.1', '7.2'], phpReleases).expect([
'5.5',
'5.6',
'7.1',
'7.2',
])
given(['7.0', '7.1', '7.2'], phpReleases).expect(['>= 7'])
given(
['5.0', '5.1', '5.2', '5.3', '5.4', '5.5', '5.6', '7.0', '7.1', '7.2'],
phpReleases,
).expect(['>= 5'])
given(['7.1', '7.2'], phpReleases).expect(['>= 7.1'])
given(['7.1'], phpReleases).expect(['7.1'])
given(['8.1'], phpReleases).expect([])
given([]).expect([])
})
})
describe('Composer version comparison', function () {
test(compare, () => {
// composer version scheme ordering
given('0.9.0', '1.0.0-alpha').expect(-1)
given('1.0.0-alpha', '1.0.0-alpha2').expect(-1)
given('1.0.0-alpha2', '1.0.0-beta').expect(-1)
given('1.0.0-beta', '1.0.0-beta2').expect(-1)
given('1.0.0-beta2', '1.0.0-RC').expect(-1)
given('1.0.0-B2', '1.0.0-RC').expect(-1)
given('1.0.0-RC', '1.0.0-RC2').expect(-1)
given('1.0.0-RC2', '1.0.0').expect(-1)
given('1.0.0-rc', '1.0.0').expect(-1)
given('1.0.0', '1.0.0-patch').expect(-1)
given('1.0.0-patch', '1.0.0-dev').expect(-1)
given('1.0.0-dev', '1.0.1').expect(-1)
given('1.0.1', '1.0.x-dev').expect(-1)
// short versions should compare equal to long versions
given('1.0.0-p', '1.0.0-patch').expect(0)
given('1.0.0-a', '1.0.0-alpha').expect(0)
given('1.0.0-A', '1.0.0-alpha').expect(0)
given('1.0.0-a2', '1.0.0-alpha2').expect(0)
given('1.0.0-b', '1.0.0-beta').expect(0)
given('1.0.0-b2', '1.0.0-beta2').expect(0)
given('1.0.0-B2', '1.0.0-beta2').expect(0)
// numeric suffixes
given('1.0.0-b1', '1.0.0-b2').expect(-1)
given('1.0.0-b10', '1.0.0-b11').expect(-1)
given('1.0.0-a1', '1.0.0-a2').expect(-1)
given('1.0.0-a10', '1.0.0-a11').expect(-1)
given('1.0.0-RC1', '1.0.0-RC2').expect(-1)
given('1.0.0-RC10', '1.0.0-RC11').expect(-1)
given('1.0.0-rc10', '1.0.0-RC11').expect(-1)
})
})