From 5c1d7186e4d07f9d5ea554d689b3439a989247b6 Mon Sep 17 00:00:00 2001 From: Danny Banks Date: Fri, 22 Jan 2021 16:18:03 -0800 Subject: [PATCH] chore(deprecation): updating buffer call in base64 converter (#522) --- __tests__/utils/convertToBase64.test.js | 5 +++++ lib/utils/convertToBase64.js | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/__tests__/utils/convertToBase64.test.js b/__tests__/utils/convertToBase64.test.js index 13d5ad122..c79005f64 100644 --- a/__tests__/utils/convertToBase64.test.js +++ b/__tests__/utils/convertToBase64.test.js @@ -36,5 +36,10 @@ describe('utils', () => { it('should return a string', () => { expect(typeof convertToBase64('__tests__/__configs/test.json')).toBe('string'); }); + + it('should be a valid base64 string', () => { + expect(convertToBase64('__tests__/__json_files/simple.json')) + .toEqual('ewogICJmb28iOiAiYmFyIiwKICAiYmFyIjogIntmb299Igp9'); + }); }); }); diff --git a/lib/utils/convertToBase64.js b/lib/utils/convertToBase64.js index 953479a35..ac6fd1e2f 100644 --- a/lib/utils/convertToBase64.js +++ b/lib/utils/convertToBase64.js @@ -24,7 +24,7 @@ function convertToBase64(filePath) { throw new Error('filePath name must be a string'); var body = fs.readFileSync(filePath, 'binary'); - return new Buffer(body, 'binary').toString('base64'); + return Buffer.from(body, 'binary').toString('base64'); } module.exports = convertToBase64;