diff --git a/src/build-index.js b/src/build-index.js index 4ffbef9..71a36f0 100644 --- a/src/build-index.js +++ b/src/build-index.js @@ -1,7 +1,5 @@ import { assign, - cond, - constant, flatMap, get, getOr, @@ -18,10 +16,11 @@ const buildIndex = (index, node) => { const value = get(index, node.value); return pipe( - cond([ - [get('dir'), getOr([], 'nodes')], - [constant(true), constant([])] - ]), + _node => { + if (get('dir', _node)) + return getOr([], 'nodes', _node); + return []; + }, flatMap(function(child) { return buildIndex(index, child); }), diff --git a/src/util/test/cli.js b/src/util/test/cli.js index 0ff98a8..9e85aa1 100644 --- a/src/util/test/cli.js +++ b/src/util/test/cli.js @@ -60,7 +60,7 @@ test('should throw error on directory sync if etcd throw unknown error', async t t.fail(); } catch (err) { - t.pass(); + t.is(err, UnknownError); } }); @@ -140,7 +140,7 @@ test('should throw error on file sync if etcd throw unknown error', async t => { t.fail(); } catch (err) { - t.pass(); + t.is(err, UnknownError); } }); diff --git a/src/util/test/etcd.js b/src/util/test/etcd.js index 27e2fe9..630e406 100644 --- a/src/util/test/etcd.js +++ b/src/util/test/etcd.js @@ -107,11 +107,12 @@ const headers = () => ({'content-type': 'application/json'}); test(`${title} raise error`, async t => { t.plan(2); + const TestError = new Error(); try { await fn$({ [fn]: (..._argz) => { const cb = _argz.pop(); - cb(new Error('za')); + cb(TestError); return { abort: () => { t.pass(); @@ -122,7 +123,7 @@ const headers = () => ({'content-type': 'application/json'}); t.fail(); } catch (err) { - t.pass(); + t.is(err, TestError); } }); });