From 2a548a95e7409e9fbbd1f0b972aad57f25764cae Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Thu, 22 Aug 2024 10:47:16 -0700 Subject: [PATCH] [Tests] `utils.merge`: add some coverage --- test/utils.js | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/test/utils.js b/test/utils.js index aa84dfdc..21429937 100644 --- a/test/utils.js +++ b/test/utils.js @@ -28,6 +28,20 @@ test('merge()', function (t) { var noOptionsNonObjectSource = utils.merge({ foo: 'baz' }, 'bar'); t.deepEqual(noOptionsNonObjectSource, { foo: 'baz', bar: true }); + var func = function f() {}; + t.deepEqual( + utils.merge(func, { foo: 'bar' }), + [func, { foo: 'bar' }], + 'functions can not be merged into' + ); + + func.bar = 'baz'; + t.deepEqual( + utils.merge({ foo: 'bar' }, func), + { foo: 'bar', 'function f() {}': true }, + 'functions can not be merge sources' + ); + t.test( 'avoids invoking array setters unnecessarily', { skip: typeof Object.defineProperty !== 'function' },