Skip to content

Commit

Permalink
Test npm pre-release caret range handling
Browse files Browse the repository at this point in the history
Signed-off-by: Keshav Priyadarshi <[email protected]>
  • Loading branch information
keshav-space committed Sep 6, 2023
1 parent 16eafff commit 865dc05
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions tests/test_version_range.py
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,39 @@ def test_NpmVersionRange_from_native_with_compatible_with_version_operator(self)
version_range = NpmVersionRange.from_native(npm_range)
assert version_range == expected

def test_NpmVersionRange_from_native_with_prerelease_carate_range(self):
npm_range = "^1.2.3-beta.1"
expected = NpmVersionRange(
constraints=(
VersionConstraint(comparator=">=", version=SemverVersion(string="1.2.3-beta.1")),
VersionConstraint(comparator="<", version=SemverVersion(string="2.0.0")),
)
)
version_range = NpmVersionRange.from_native(npm_range)
assert version_range == expected

def test_NpmVersionRange_from_native_with_prerelease_carate_range_wihtout_major(self):
npm_range = "^0.2.1-beta"
expected = NpmVersionRange(
constraints=(
VersionConstraint(comparator=">=", version=SemverVersion(string="0.2.1-beta")),
VersionConstraint(comparator="<", version=SemverVersion(string="0.3.0")),
)
)
version_range = NpmVersionRange.from_native(npm_range)
assert version_range == expected

def test_NpmVersionRange_from_native_with_prerelease_carate_range_wihtout_major_and_minor(self):
npm_range = "^0.0.2-beta"
expected = NpmVersionRange(
constraints=(
VersionConstraint(comparator=">=", version=SemverVersion(string="0.0.2-beta")),
VersionConstraint(comparator="<", version=SemverVersion(string="0.0.3")),
)
)
version_range = NpmVersionRange.from_native(npm_range)
assert version_range == expected

def test_NpmVersionRange_from_native_with_approximately_equal_to_operator(self):
npm_range = "~3.8.2"
expected = NpmVersionRange(
Expand Down

0 comments on commit 865dc05

Please sign in to comment.