
* Extract semver compatibility logic to shared package and implement it in taxes * Move semver checking package to packages/shared * Update lock * Apply suggestions from code review Co-authored-by: Adrian Pilarczyk <admin@peelar.dev> * Improve error message * Fix lockfile --------- Co-authored-by: Adrian Pilarczyk <admin@peelar.dev>
32 lines
1 KiB
TypeScript
32 lines
1 KiB
TypeScript
import { describe, expect, it } from "vitest";
|
|
import { SaleorVersionCompatibilityValidator } from "./saleor-version-compatibility-validator";
|
|
|
|
describe("SaleorVersionCompatibilityValidator", () => {
|
|
it.each([
|
|
[">=3.10 <4", "3.12.0"],
|
|
[">=3.10 <4", "3.999.0"],
|
|
[">=3.10", "4.0.0"],
|
|
[">=3.10", "4.1.0"],
|
|
[">3.10", "3.11.0"],
|
|
/**
|
|
* -a suffix is Saleor staging version indicator
|
|
*/
|
|
[">=3.10", "3.10.0-a"],
|
|
[">3.10", "3.11.0-a"],
|
|
])('Passes for app requirement "%s" and saleor version "%s"', (appVersionReq, saleorVersion) => {
|
|
expect(() =>
|
|
new SaleorVersionCompatibilityValidator(appVersionReq).validateOrThrow(saleorVersion)
|
|
).not.to.throw();
|
|
});
|
|
|
|
it.each([
|
|
[">=3.10 <4", "4.0.0"],
|
|
[">3.10 <4", "3.10.0"],
|
|
[">3.10", "3.10.0"],
|
|
[">=3.10", "2.0.0"],
|
|
])('Throws for app requirement "%s" and saleor version "%s"', (appVersionReq, saleorVersion) => {
|
|
expect(() =>
|
|
new SaleorVersionCompatibilityValidator(appVersionReq).validateOrThrow(saleorVersion)
|
|
).to.throw();
|
|
});
|
|
});
|