From fc9a8701f628d518f3c9cb83fc101da8f4f13f0a Mon Sep 17 00:00:00 2001 From: Erica Marigold Date: Tue, 12 Nov 2024 20:23:51 +0530 Subject: [PATCH] chore(tests): migrate parse_valid to use official frktest package Also removes `any` casts since https://github.com/itsfrank/frktest/issues/2 was resolved. --- tests/parse_valid.luau | 105 ++++++++++++++++++++--------------------- 1 file changed, 51 insertions(+), 54 deletions(-) diff --git a/tests/parse_valid.luau b/tests/parse_valid.luau index 7167054..8842d4b 100644 --- a/tests/parse_valid.luau +++ b/tests/parse_valid.luau @@ -1,4 +1,4 @@ -local frktest = require("../lune_packages/frktest").core +local frktest = require("@pkg/frktest") local test = frktest.test local check = frktest.assert.check @@ -7,69 +7,66 @@ type Option = Option.Option local Semver = require("../lib") --- FIXME: Any casts all over the place, because of frktest not being correctly typed --- See https://github.com/itsfrank/frktest/issues/2 - return function() - test.suite("Basic tests", function() - test.case("Semver creates valid version objects", function() - local res = Semver.parse("1.2.3-beta.1") - check.is_true(res:isOk()) + test.suite("Basic tests", function() + test.case("Semver creates valid version objects", function() + local res = Semver.parse("1.2.3-beta.1") + check.is_true(res:isOk()) - local version = res:unwrap() - check.equal(version.major, 1) - check.equal(version.minor, 2) - check.equal(version.patch, 3) - end) + local version = res:unwrap() + check.equal(version.major, 1) + check.equal(version.minor, 2) + check.equal(version.patch, 3) + end) - test.case("Semver handles prerelease versions", function() - local res = Semver.parse("1.2.3-beta.1") - check.is_true(res:isOk()) + test.case("Semver handles prerelease versions", function() + local res = Semver.parse("1.2.3-beta.1") + check.is_true(res:isOk()) - local version = res:unwrap() - check.equal(version.major, 1) - check.equal(version.minor, 2) - check.equal(version.patch, 3) + local version = res:unwrap() + check.equal(version.major, 1) + check.equal(version.minor, 2) + check.equal(version.patch, 3) - check.table.equal( - version.prerelease :: any, - Option.Some({ - type = "beta", - ordinal = Option.Some(1), - }) :: any - ) - end) + check.table.equal( + version.prerelease, + Option.Some({ + type = "beta", + ordinal = Option.Some(1), + }) + ) + end) - test.case("Semver handles build metadata", function() - local res = Semver.parse("1.2.3+build.123") - check.is_true(res:isOk()) + test.case("Semver handles build metadata", function() + local res = Semver.parse("1.2.3+build.123") + check.is_true(res:isOk()) - local version = res:unwrap() + local version = res:unwrap() - check.equal(version.major, 1) - check.equal(version.minor, 2) - check.equal(version.patch, 3) - check.table.equal(version.buildMetadata :: any, Option.Some("build.123") :: any) - end) + check.equal(version.major, 1) + check.equal(version.minor, 2) + check.equal(version.patch, 3) + check.table.equal(version.buildMetadata, Option.Some("build.123")) + end) - test.case("Semver handles prerelease versions with build metadata", function() - local res = Semver.parse("1.2.3-beta.1+build.123") - check.is_true(res:isOk()) + test.case("Semver handles prerelease versions with build metadata", function() + local res = Semver.parse("1.2.3-beta.1+build.123") + check.is_true(res:isOk()) - local version = res:unwrap() - check.equal(version.major, 1) - check.equal(version.minor, 2) - check.equal(version.patch, 3) + local version = res:unwrap() + check.equal(version.major, 1) + check.equal(version.minor, 2) + check.equal(version.patch, 3) - check.table.equal( - version.prerelease :: any, - Option.Some({ - type = "beta", - ordinal = Option.Some(1), - }) :: any - ) + check.table.equal( + version.prerelease, + Option.Some({ + type = "beta", + ordinal = Option.Some(1), + }) + ) - check.table.equal(version.buildMetadata :: any, Option.Some("build.123") :: any) - end) - end) + check.table.equal(version.buildMetadata, Option.Some("build.123")) + end) + end) end