Skip to content

Commit

Permalink
test(keys): Unit tests for PKProvider.keyFromValue
Browse files Browse the repository at this point in the history
  • Loading branch information
jcowman2 committed Sep 6, 2019
1 parent 8ca4741 commit ca02198
Showing 1 changed file with 14 additions and 6 deletions.
20 changes: 14 additions & 6 deletions test/unit/keys.test.ts
@@ -1,12 +1,8 @@
import { expect } from "chai";
import "mocha";

import {
FK,
ReservedPKSet,
PKProvider,
buildPKProvider
} from "../../src/common";
import { ReservedPKSet, buildPKProvider } from "../../src/common";
import { RegalError } from "../../src";

interface Dummy {}
const RESERVED_KEYS: ReservedPKSet<Dummy> = {
Expand Down Expand Up @@ -253,4 +249,16 @@ describe("Keys", function() {
.equals(fork.next())
).to.be.true;
});

it("PKProvider.keyFromValue creates a key from a valid value", function() {
const prov = buildPKProvider();
const first = prov.next();
expect(first.equals(prov.keyFromValue(first.value()))).to.be.true;
});

it("PKProvider.keyFromValue throws an error if the value is invalid", function() {
expect(() => buildPKProvider().keyFromValue("bork")).to.throw(
RegalError
);
});
});

0 comments on commit ca02198

Please sign in to comment.