Skip to content

Commit

Permalink
fix(primitives): fixed base64Binary spelling
Browse files Browse the repository at this point in the history
Changed spellling from base64binary to base64Binary to match FHIR spec.
  • Loading branch information
tangdrew committed Feb 17, 2019
1 parent a40557a commit 7d64ee1
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 12 deletions.
4 changes: 2 additions & 2 deletions packages/primitives/src/R4/base64binary.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export class Base64BinaryType extends Type<string> {
readonly _tag: "Base64BinaryType" = "Base64BinaryType";
constructor() {
super(
"base64binary",
"base64Binary",
(m): m is string => typeof m === "string" && BASE64_BINARY_REGEX.test(m),
(m, c) => (this.is(m) ? success(m) : failure(m, c)),
identity
Expand All @@ -21,4 +21,4 @@ export class Base64BinaryType extends Type<string> {
/**
* A stream of bytes, base64 encoded.
*/
export const base64binary = new Base64BinaryType();
export const base64Binary = new Base64BinaryType();
4 changes: 2 additions & 2 deletions packages/primitives/src/R4/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* FHIR R4 Primitive Runtime Types
*/

import { Base64BinaryType, base64binary } from "./base64binary";
import { Base64BinaryType, base64Binary } from "./base64Binary";
import { BooleanType, boolean } from "./boolean";
import { CanonicalType, canonical } from "./canonical";
import { CodeType, code } from "./code";
Expand All @@ -23,7 +23,7 @@ import { URLType, url } from "./url";
import { UUIDType, uuid } from "./uuid";

export {
base64binary,
base64Binary,
Base64BinaryType,
boolean,
BooleanType,
Expand Down
16 changes: 8 additions & 8 deletions packages/primitives/test/R4/base64binary.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,35 +2,35 @@
* Tests for Base64Binary Runtime Type
*/

import { base64binary } from "../../src/R4";
import { base64Binary } from "../../src/R4";
import { assertSuccess, assertFailure, assertStrictEqual } from "./helpers";

describe("Base64BinaryType", () => {
it("should succeed validating a valid value", () => {
const T = base64binary;
const T = base64Binary;
assertSuccess(T.decode("aGVsbG8gd29ybGQ="));
});

it("should return the same reference if validation succeeded and nothing changed", () => {
const T = base64binary;
const T = base64Binary;
const value = "aGVsbG8gd29ybGQ=";
assertStrictEqual(T.decode(value), value);
});

it("should fail validating an invalid value", () => {
const T = base64binary;
assertFailure(T.decode(2), ["Invalid value 2 supplied to : base64binary"]);
const T = base64Binary;
assertFailure(T.decode(2), ["Invalid value 2 supplied to : base64Binary"]);
});

it("should fail validating a string with invalid characters", () => {
const T = base64binary;
const T = base64Binary;
assertFailure(T.decode("\0"), [
'Invalid value "\\u0000" supplied to : base64binary'
'Invalid value "\\u0000" supplied to : base64Binary'
]);
});

it("should type guard", () => {
const T = base64binary;
const T = base64Binary;
expect(T.is("aGVsbG8gd29ybGQ=")).toEqual(true);
expect(T.is(true)).toEqual(false);
expect(T.is(undefined)).toEqual(false);
Expand Down

0 comments on commit 7d64ee1

Please sign in to comment.