urns
Version:
An RFC 8141 compliant URN library with some interesting type related functionality
17 lines (16 loc) • 771 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
var map_fields_1 = require("./map-fields");
describe("Test decoding", function () {
it("should extract just one string", function () {
var result = map_fields_1.mapFields(["id"])("foo");
expect(result).toEqual({ id: "foo" });
});
it("should extract two strings", function () {
var result = map_fields_1.mapFields(["id1", "id2"])("foo:bar");
expect(result).toEqual({ id1: "foo", id2: "bar" });
});
it("should throw an error due to mismatch in number of fields", function () {
expect(function () { return map_fields_1.mapFields(["id1", "id2"])("foo:bar:buz"); }).toThrow("Expected nss with 2 segments but got foo:bar:buz");
});
});