Skip to content

Commit

Permalink
relocate installer test
Browse files Browse the repository at this point in the history
  • Loading branch information
pablomendezroyo committed Oct 31, 2023
1 parent 81aea2e commit 3e6e1ba
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 40 deletions.
40 changes: 0 additions & 40 deletions packages/dappmanager/test/unit/utils/validate.test.ts

This file was deleted.

20 changes: 20 additions & 0 deletions packages/installer/test/unit/installer/isIpfsHash.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import "mocha";
import { expect } from "chai";
import { mockHash } from "../../testUtils.js";
import { isIpfsHash } from "../../../src/utils.js";

describe("isIpfsHash", () => {
const validHashes = [
mockHash,
"/ipfs/QmYwAPJzv5CZsnA625s3Xf2nemtYgPpHdWEz79ojWnPbdG/readme",
"QmYwAPJzv5CZsnA625s3Xf2nemtYgPpHdWEz79ojWnPbdG/readme",
"/ipfs/QmPZ9gcCEpqKTo6aq61g2nXGUhM4iCL3ewB6LDXZCtioEB",
"QmPZ9gcCEpqKTo6aq61g2nXGUhM4iCL3ewB6LDXZCtioEB",
];

for (const hash of validHashes) {
it(`valid hash ${hash}`, () => {
expect(isIpfsHash(hash)).to.equal(true);
});
}
});
21 changes: 21 additions & 0 deletions packages/installer/test/unit/release/isSemverRange.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import "mocha";
import { expect } from "chai";
import { isSemverRange } from "../../../src/release/validate.js";

describe("isSemverRange", () => {
it("should return true for a regular semver", () => {
expect(isSemverRange("0.1.2")).to.equal(true);
});
it("should return true for a '*' semver", () => {
expect(isSemverRange("*")).to.equal(true);
});
it("should return true for a semver range", () => {
expect(isSemverRange("^0.1.2")).to.equal(true);
});
it("should return false for an IPFS range", () => {
expect(isSemverRange("/ipfs/Qmasbjdbkajbdkjwbkjfbakjsf")).to.equal(false);
});
it("should return false for random nonsense", () => {
expect(isSemverRange("asjd")).to.equal(false);
});
});

0 comments on commit 3e6e1ba

Please sign in to comment.