Skip to content

Commit

Permalink
chore(tests): Fix broken tests
Browse files Browse the repository at this point in the history
  • Loading branch information
kofno committed Nov 22, 2019
1 parent e36593c commit cf77dae
Showing 1 changed file with 22 additions and 16 deletions.
38 changes: 22 additions & 16 deletions tests/Decoder.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,19 @@
import * as test from 'tape';
import { array, at, boolean, date, dict, field, keyValuePairs, maybe, nullable, number, oneOf, string, succeed } from '../src/index';
import {
array,
at,
boolean,
date,
dict,
field,
keyValuePairs,
maybe,
nullable,
number,
oneOf,
string,
succeed,
} from '../src/index';

test('string decoder', t => {
string.decodeJson('"foo"').cata({
Expand Down Expand Up @@ -137,7 +151,8 @@ test('at decoder', t => {
at(['foo', 0, 'bar'], number)
.decodeAny(undefined)
.cata({
Err: () => t.pass(`at-ing an undefined to should be an error, but not crash`),
Err: () =>
t.pass(`at-ing an undefined to should be an error, but not crash`),
Ok: () => t.fail(`at-ing an undefined should not pass`),
});

Expand Down Expand Up @@ -367,19 +382,6 @@ test('oneOf', t => {
t.end();
});

test('applicative', t => {
const ctor = (s: string) => (n: number) => ({ s, n });
const decoder = succeed(ctor)
.ap(field('foo', string))
.ap(field('bar', number));

decoder.decodeAny({ foo: 'baz', bar: 42 }).cata({
Err: m => t.fail(`should have succeeded: ${m}`),
Ok: v => t.pass(`Worked!: ${JSON.stringify(v)}`),
});
t.end();
});

test('keyValuePairs', t => {
const decoder = keyValuePairs(number);

Expand All @@ -395,7 +397,11 @@ test('keyValuePairs', t => {

decoder.decodeAny({ foo: 42, bar: 2 }).cata({
Err: m => t.fail(`should have passed: ${m}`),
Ok: v => t.deepEqual(v, [['foo', 42], ['bar', 2]]),
Ok: v =>
t.deepEqual(v, [
['foo', 42],
['bar', 2],
]),
});

t.end();
Expand Down

0 comments on commit cf77dae

Please sign in to comment.