[READ-ONLY] a fast, modern browser for the npm registry
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

test: add isExactVersions tests (#893)

authored by

James Garbutt and committed by
GitHub
c4755ed4 5df6ffee

+34
+34
test/unit/app/utils/versions.spec.ts
··· 6 6 getPrereleaseChannel, 7 7 getVersionGroupKey, 8 8 getVersionGroupLabel, 9 + isExactVersion, 9 10 isSameVersionGroup, 10 11 parseVersion, 11 12 sortTags, 12 13 } from '../../../../app/utils/versions' 14 + 15 + describe('isExactVersion', () => { 16 + it('returns true for stable versions', () => { 17 + expect(isExactVersion('1.0.0')).toBe(true) 18 + expect(isExactVersion('0.1.0')).toBe(true) 19 + expect(isExactVersion('10.20.30')).toBe(true) 20 + }) 21 + 22 + it('returns true for prerelease versions', () => { 23 + expect(isExactVersion('1.0.0-beta.1')).toBe(true) 24 + expect(isExactVersion('1.0.0-alpha.0')).toBe(true) 25 + expect(isExactVersion('5.8.0-rc')).toBe(true) 26 + }) 27 + 28 + it('returns false for ranges', () => { 29 + expect(isExactVersion('^1.0.0')).toBe(false) 30 + expect(isExactVersion('~1.0.0')).toBe(false) 31 + expect(isExactVersion('>=1.0.0')).toBe(false) 32 + expect(isExactVersion('1.0.x')).toBe(false) 33 + expect(isExactVersion('*')).toBe(false) 34 + }) 35 + 36 + it('returns false for dist-tags', () => { 37 + expect(isExactVersion('latest')).toBe(false) 38 + expect(isExactVersion('next')).toBe(false) 39 + expect(isExactVersion('beta')).toBe(false) 40 + }) 41 + 42 + it('returns false for invalid strings', () => { 43 + expect(isExactVersion('')).toBe(false) 44 + expect(isExactVersion('not-a-version')).toBe(false) 45 + }) 46 + }) 13 47 14 48 describe('parseVersion', () => { 15 49 it('parses stable versions', () => {