From 18fd7b16ffcd90112f54f2da1d55f2f00b8cad4d Mon Sep 17 00:00:00 2001 From: Luke Childs Date: Tue, 23 May 2017 14:21:50 +0700 Subject: [PATCH] Update tests to reflect new b64 behaviour --- test/b64.js | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/test/b64.js b/test/b64.js index 9c3af5b..f554d9f 100644 --- a/test/b64.js +++ b/test/b64.js @@ -6,15 +6,18 @@ test('b64 is a function', t => { t.is(typeof b64, 'function'); }); -test('b64 calls b64[opts.method]', async t => { - const encodeResult = await b64(values.buffer, { method: 'encode' }); - const decodeResult = await b64(values.base64, { method: 'decode' }); - t.is(encodeResult, values.base64); - t.true(decodeResult instanceof Buffer); - t.is(decodeResult.toString(), values.string); +test('b64 calls b64.encode on buffers', async t => { + const result = await b64(values.buffer); + t.is(result, values.base64); }); -test('b64 rejects Promise if method is not \'encode\' or \'decode\'', async t => { - const error = await t.throws(b64(values.buffer)); - t.is(error.message, 'opts.method must be \'encode\' or \'decode\'.'); +test('b64 calls b64.decode on strings', async t => { + const result = await b64(values.base64); + t.true(result instanceof Buffer); + t.is(result.toString(), values.string); +}); + +test('b64 rejects Promise if input is not a buffer or string', async t => { + const error = await t.throws(b64(0)); + t.is(error.message, 'input must be a buffer or string'); });