From 75162b8b79dff0a68c89be1d01c5a7c7b26d4a5d Mon Sep 17 00:00:00 2001 From: Klemek Date: Tue, 16 Jul 2019 15:09:49 +0200 Subject: [PATCH] more unit tests --- src/rendering.js | 3 +++ test/rendering.test.js | 16 ++++++++++++++++ 2 files changed, 19 insertions(+) diff --git a/src/rendering.js b/src/rendering.js index c6c104e..9a82f79 100644 --- a/src/rendering.js +++ b/src/rendering.js @@ -129,6 +129,9 @@ module.exports = (options) => { return null; if (typeof icon === 'object') { + if (!icon.path || !icon.path.trim()) + return null; + icon.height = icon.height || icon.width || resources.height; icon.width = icon.width || icon.height; return icon; diff --git a/test/rendering.test.js b/test/rendering.test.js index 14a3a78..1d39bf1 100644 --- a/test/rendering.test.js +++ b/test/rendering.test.js @@ -171,6 +171,22 @@ describe('getIcon', () => { height: 512 }); }); + test('custom invalid icon', () => { + const res = rendering().getIcon({ + paht: 'hello', + width: 80, + height: 160 + }); + expect(res).toBe(null); + }); + test('custom invalid icon 2', () => { + const res = rendering().getIcon({ + path: '', + width: 80, + height: 160 + }); + expect(res).toBe(null); + }); }); describe('getLinkPath (non-regression)', () => {