Skip to content

Commit

Permalink
chore: add tests for test function
Browse files Browse the repository at this point in the history
  • Loading branch information
Nebulis committed Dec 26, 2019
1 parent 47a7c25 commit 7012bd0
Show file tree
Hide file tree
Showing 3 changed files with 115 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,46 @@ import { documentRopstenValidWithCertificateStore } from "../../../test/fixtures
import { documentRopstenNotIssuedWithDocumentStore } from "../../../test/fixtures/v2/documentRopstenNotIssuedWithDocumentStore";
import { documentRopstenNotIssuedWithCertificateStore } from "../../../test/fixtures/v2/documentRopstenNotIssuedWithCertificateStore";
import { documentRopstenValidWithDocumentStore as v2documentRopstenValidWithDocumentStore } from "../../../test/fixtures/v2/documentRopstenValidWithDocumentStore";
import { documentRopstenValidWithDocumentStore } from "../../../test/fixtures/v3/documentRopstenValid";
import {
documentRopstenValidWithDocumentStore,
documentRopstenValidWithTokenRegistry
} from "../../../test/fixtures/v3/documentRopstenValid";
import { documentRopstenNotIssued } from "../../../test/fixtures/v3/documentRopstenNotIssued";
import { documentRopstenNotIssuedWithTokenRegistry } from "../../../test/fixtures/v2/documentRopstenNotIssuedWithTokenRegistry";

describe("openAttestationEthereumDocumentStoreIssued", () => {
describe("test", () => {
it("should return true when v2 document has at least one certificate store", () => {
const test = openAttestationEthereumDocumentStoreIssued.test(documentRopstenNotIssuedWithCertificateStore, {
network: "ropsten"
});
expect(test).toStrictEqual(true);
});
it("should return true when v2 document has at least one document store", () => {
const test = openAttestationEthereumDocumentStoreIssued.test(documentRopstenNotIssuedWithDocumentStore, {
network: "ropsten"
});
expect(test).toStrictEqual(true);
});
it("should return false when v2 document uses token registry", () => {
const test = openAttestationEthereumDocumentStoreIssued.test(documentRopstenNotIssuedWithTokenRegistry, {
network: "ropsten"
});
expect(test).toStrictEqual(false);
});
it("should return true when v3 document uses DOCUMENT_STORE method", () => {
const test = openAttestationEthereumDocumentStoreIssued.test(documentRopstenValidWithDocumentStore, {
network: "ropsten"
});
expect(test).toStrictEqual(true);
});
it("should return false when v3 document uses TOKEN_REGISTRY method", () => {
const test = openAttestationEthereumDocumentStoreIssued.test(documentRopstenValidWithTokenRegistry, {
network: "ropsten"
});
expect(test).toStrictEqual(false);
});
});
describe("v2", () => {
it("should return an invalid fragment when document with certificate store has not been issued", async () => {
const fragment = await openAttestationEthereumDocumentStoreIssued.verify(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,47 @@ import { documentRopstenRevokedWithDocumentStore } from "../../../test/fixtures/
import { documentRopstenNotIssuedWithDocumentStore } from "../../../test/fixtures/v2/documentRopstenNotIssuedWithDocumentStore";
import { documentRopstenRevokedWithCertificateStore } from "../../../test/fixtures/v2/documentRopstenRevokedWithCertificateStore";
import { documentRopstenNotIssuedWithCertificateStore } from "../../../test/fixtures/v2/documentRopstenNotIssuedWithCertificateStore";
import { documentRopstenValidWithDocumentStore as v3documentRopstenValidWithDocumentStore } from "../../../test/fixtures/v3/documentRopstenValid";
import {
documentRopstenValidWithDocumentStore as v3documentRopstenValidWithDocumentStore,
documentRopstenValidWithTokenRegistry
} from "../../../test/fixtures/v3/documentRopstenValid";
import { documentRopstenRevoked } from "../../../test/fixtures/v3/documentRopstenRevoked";
import { openAttestationEthereumDocumentStoreIssued } from "../documentStoreIssued/openAttestationEthereumDocumentStoreIssued";
import { documentRopstenValidWithDocumentStore as v2documentRopstenValidWithDocumentStore } from "../../../test/fixtures/v2/documentRopstenValidWithDocumentStore";
import { documentRopstenNotIssuedWithTokenRegistry } from "../../../test/fixtures/v2/documentRopstenNotIssuedWithTokenRegistry";

describe("openAttestationEthereumDocumentStoreRevoked", () => {
describe("test", () => {
it("should return true when v2 document has at least one certificate store", () => {
const test = openAttestationEthereumDocumentStoreRevoked.test(documentRopstenNotIssuedWithCertificateStore, {
network: "ropsten"
});
expect(test).toStrictEqual(true);
});
it("should return true when v2 document has at least one document store", () => {
const test = openAttestationEthereumDocumentStoreRevoked.test(documentRopstenNotIssuedWithDocumentStore, {
network: "ropsten"
});
expect(test).toStrictEqual(true);
});
it("should return false when v2 document uses token registry", () => {
const test = openAttestationEthereumDocumentStoreRevoked.test(documentRopstenNotIssuedWithTokenRegistry, {
network: "ropsten"
});
expect(test).toStrictEqual(false);
});
it("should return true when v3 document uses DOCUMENT_STORE method", () => {
const test = openAttestationEthereumDocumentStoreRevoked.test(v3documentRopstenValidWithDocumentStore, {
network: "ropsten"
});
expect(test).toStrictEqual(true);
});
it("should return false when v3 document uses TOKEN_REGISTRY method", () => {
const test = openAttestationEthereumDocumentStoreRevoked.test(documentRopstenValidWithTokenRegistry, {
network: "ropsten"
});
expect(test).toStrictEqual(false);
});
});
describe("v2", () => {
it("should return an invalid fragment when document with document store has been revoked", async () => {
const fragment = await openAttestationEthereumDocumentStoreRevoked.verify(
Expand Down Expand Up @@ -101,7 +136,7 @@ describe("openAttestationEthereumDocumentStoreRevoked", () => {
});
});
it("should return an error fragment when document mixes document store and other verifier method", async () => {
const fragment = await openAttestationEthereumDocumentStoreIssued.verify(
const fragment = await openAttestationEthereumDocumentStoreRevoked.verify(
{
...v2documentRopstenValidWithDocumentStore,
data: {
Expand All @@ -120,7 +155,7 @@ describe("openAttestationEthereumDocumentStoreRevoked", () => {
}
);
expect(fragment).toStrictEqual({
name: "OpenAttestationEthereumDocumentStoreIssued",
name: "OpenAttestationEthereumDocumentStoreRevoked",
type: "DOCUMENT_STATUS",
data: new Error(`No document store for issuer "Foo Issuer"`),
message: `No document store for issuer "Foo Issuer"`,
Expand Down
41 changes: 39 additions & 2 deletions src/verifiers/openAttestationEthereumTokenRegistryMinted.test.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,47 @@
import { openAttestationEthereumTokenRegistryMinted } from "./openAttestationEthereumTokenRegistryMinted";
import { documentRopstenNotIssuedWithTokenRegistry } from "../../test/fixtures/v2/documentRopstenNotIssuedWithTokenRegistry";
import { documentRopstenValidWithToken } from "../../test/fixtures/v2/documentRopstenValidWithToken";
import { documentRopstenValidWithTokenRegistry as v3documentRopstenValidWithTokenRegistry } from "../../test/fixtures/v3/documentRopstenValid";
import {
documentRopstenValidWithDocumentStore as v3documentRopstenValidWithDocumentStore,
documentRopstenValidWithTokenRegistry as v3documentRopstenValidWithTokenRegistry
} from "../../test/fixtures/v3/documentRopstenValid";
import { documentRopstenNotIssuedWithTokenRegistry as v3documentRopstenNotIssuedWithTokenRegistry } from "../../test/fixtures/v3/documentRopstenNotIssuedWithTokenRegistry";
import { documentRopstenNotIssuedWithCertificateStore } from "../../test/fixtures/v2/documentRopstenNotIssuedWithCertificateStore";
import { documentRopstenNotIssuedWithDocumentStore } from "../../test/fixtures/v2/documentRopstenNotIssuedWithDocumentStore";

describe("openAttestationEthereumTokenRegistryIssued", () => {
describe("openAttestationEthereumTokenRegistryMinted", () => {
describe("test", () => {
it("should return false when v2 document uses certificate store", () => {
const test = openAttestationEthereumTokenRegistryMinted.test(documentRopstenNotIssuedWithCertificateStore, {
network: "ropsten"
});
expect(test).toStrictEqual(false);
});
it("should return false when v2 document uses document store", () => {
const test = openAttestationEthereumTokenRegistryMinted.test(documentRopstenNotIssuedWithDocumentStore, {
network: "ropsten"
});
expect(test).toStrictEqual(false);
});
it("should return true when v2 document has at least one token registry", () => {
const test = openAttestationEthereumTokenRegistryMinted.test(documentRopstenNotIssuedWithTokenRegistry, {
network: "ropsten"
});
expect(test).toStrictEqual(true);
});
it("should return false when v3 document uses DOCUMENT_STORE method", () => {
const test = openAttestationEthereumTokenRegistryMinted.test(v3documentRopstenValidWithDocumentStore, {
network: "ropsten"
});
expect(test).toStrictEqual(false);
});
it("should return true when v3 document uses TOKEN_REGISTRY method", () => {
const test = openAttestationEthereumTokenRegistryMinted.test(v3documentRopstenNotIssuedWithTokenRegistry, {
network: "ropsten"
});
expect(test).toStrictEqual(true);
});
});
describe("v2", () => {
it("should return an invalid fragment when document with token registry has not been minted", async () => {
const fragment = await openAttestationEthereumTokenRegistryMinted.verify(
Expand Down

0 comments on commit 7012bd0

Please sign in to comment.