1
0
mirror of https://github.com/badges/shields.git synced 2025-11-15 10:01:09 +03:00

[PyPI] Fixes Python versions order by using proper Semver comparison (#6000)

* [PyPI] Fixes Python versions order by using proper Semver comparison

* [PyPI] Adds a proper specification file for Python versions service

Co-authored-by: repo-ranger[bot] <39074581+repo-ranger[bot]@users.noreply.github.com>
This commit is contained in:
Samuel FORESTIER
2021-01-02 18:17:09 +00:00
committed by GitHub
parent 79ff825504
commit d3a7afdec0
2 changed files with 44 additions and 1 deletions

View File

@@ -0,0 +1,38 @@
'use strict'
const { test, given } = require('sazerac')
const { render } = require('./pypi-python-versions.service')
describe('PyPI Python Version', function () {
test(render, function () {
// Major versions are hidden if minor are present.
given({ versions: ['3', '3.4', '3.5', '3.6', '2', '2.7'] }).expect({
message: '2.7 | 3.4 | 3.5 | 3.6',
color: 'blue',
})
// Major versions are shown when minor are missing.
given({ versions: ['2', '3'] }).expect({
message: '2 | 3',
color: 'blue',
})
// Versions are properly sorted according to their Semver segments.
given({ versions: ['3.10', '3.9', '3.8', '3.7', '3.6'] }).expect({
message: '3.6 | 3.7 | 3.8 | 3.9 | 3.10',
color: 'blue',
})
// Only "one" version works too.
given({ versions: ['3', '3.9'] }).expect({
message: '3.9',
color: 'blue',
})
// Versions are missing...
given({ versions: [] }).expect({
message: 'missing',
color: 'red',
})
})
})