Skip to content

Commit

Permalink
More tests
Browse files Browse the repository at this point in the history
  • Loading branch information
mskelton committed Mar 21, 2024
1 parent 5c205a8 commit 0a06057
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
3 changes: 1 addition & 2 deletions src/utils.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { Manifest } from "@yarnpkg/core"
import { fromUrl } from "hosted-git-info"
import semver from "semver"
import { fn } from "typanion"

export const truthy = Boolean as unknown as <T>(
arg: T | undefined | null | false
Expand Down Expand Up @@ -42,7 +41,7 @@ export function isVersionOutdated(current: string, latest: string) {
const latestPrerelease = semver.prerelease(latest)
const currentPrerelease = semver.prerelease(current)

if (latestPrerelease && currentPrerelease) {
if (semver.eq(current, latest) && latestPrerelease && currentPrerelease) {
return semver.lt(
parsePreRelease(currentPrerelease),
parsePreRelease(latestPrerelease)
Expand Down
7 changes: 7 additions & 0 deletions test/specs/outdated.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -236,8 +236,15 @@ test("isVersionOutdated", () => {
expect(isVersionOutdated("1.0.0", "1.0.1")).toBe(true)
expect(isVersionOutdated("1.0.0", "1.0.1-rc.1")).toBe(true)

// Old pre-release
expect(isVersionOutdated("1.0.0-rc.1", "1.0.0")).toBe(true)
expect(isVersionOutdated("1.0.0-rc.1", "1.0.1")).toBe(true)
expect(isVersionOutdated("1.0.0-rc.1", "1.0.0-rc.1")).toBe(false)
expect(isVersionOutdated("1.0.0-rc.1", "1.0.0-rc.2")).toBe(true)
expect(isVersionOutdated("1.0.0-rc.1", "1.0.1-rc.1")).toBe(true)

// Pre-release past the latest non-pre-release
expect(isVersionOutdated("1.0.1-rc.1", "1.0.0")).toBe(false)
expect(isVersionOutdated("1.0.1-rc.1", "1.0.0-rc.1")).toBe(false)
expect(isVersionOutdated("1.0.1-rc.1", "1.0.1-rc.1")).toBe(false)
})

0 comments on commit 0a06057

Please sign in to comment.