diff options
author | Florian Dold <florian.dold@gmail.com> | 2019-12-16 12:53:22 +0100 |
---|---|---|
committer | Florian Dold <florian.dold@gmail.com> | 2019-12-16 12:53:22 +0100 |
commit | fa4621e70c48500a372504eb8ae9b9481531c555 (patch) | |
tree | 50c457c8c2133dfec32cb465e1b3902ce88fb209 /src/util/codec-test.ts | |
parent | 1b9c5855a8afb6833ff7a706f5bed5650e1191ad (diff) | |
download | wallet-core-fa4621e70c48500a372504eb8ae9b9481531c555.tar.xz |
history events WIP
Diffstat (limited to 'src/util/codec-test.ts')
-rw-r--r-- | src/util/codec-test.ts | 26 |
1 files changed, 10 insertions, 16 deletions
diff --git a/src/util/codec-test.ts b/src/util/codec-test.ts index 22f6a0a98..7c7c93c7b 100644 --- a/src/util/codec-test.ts +++ b/src/util/codec-test.ts @@ -19,13 +19,7 @@ */ import test from "ava"; -import { - stringCodec, - objectCodec, - unionCodec, - Codec, - stringConstCodec, -} from "./codec"; +import { Codec, makeCodecForObject, makeCodecForConstString, codecForString, makeCodecForUnion } from "./codec"; interface MyObj { foo: string; @@ -44,8 +38,8 @@ interface AltTwo { type MyUnion = AltOne | AltTwo; test("basic codec", t => { - const myObjCodec = objectCodec<MyObj>() - .property("foo", stringCodec) + const myObjCodec = makeCodecForObject<MyObj>() + .property("foo", codecForString) .build("MyObj"); const res = myObjCodec.decode({ foo: "hello" }); t.assert(res.foo === "hello"); @@ -56,15 +50,15 @@ test("basic codec", t => { }); test("union", t => { - const altOneCodec: Codec<AltOne> = objectCodec<AltOne>() - .property("type", stringConstCodec("one")) - .property("foo", stringCodec) + const altOneCodec: Codec<AltOne> = makeCodecForObject<AltOne>() + .property("type", makeCodecForConstString("one")) + .property("foo", codecForString) .build("AltOne"); - const altTwoCodec: Codec<AltTwo> = objectCodec<AltTwo>() - .property("type", stringConstCodec("two")) - .property("bar", stringCodec) + const altTwoCodec: Codec<AltTwo> = makeCodecForObject<AltTwo>() + .property("type", makeCodecForConstString("two")) + .property("bar", codecForString) .build("AltTwo"); - const myUnionCodec: Codec<MyUnion> = unionCodec<MyUnion>() + const myUnionCodec: Codec<MyUnion> = makeCodecForUnion<MyUnion>() .discriminateOn("type") .alternative("one", altOneCodec) .alternative("two", altTwoCodec) |